最近考虑将跑在Vultr上的qianyong.me个人博客,使用的是ghost平台,迁移到AWS上去,同时准备使用docker来部署,把过程记录一下。

  1. 准备服务器, 安装dockerdocker-compose
sudo apt-get update
sudo apt-get install -y \
    apt-transport-https \
    ca-certificates \
    curl \
    software-properties-common

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo apt-key fingerprint 0EBFCD88
sudo add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   stable"
sudo apt-get update
sudo apt-get install -y docker-ce
sudo usermod -aG docker $USER

sudo curl -L "https://github.com/docker/compose/releases/download/1.22.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
docker-compose --version

2. 登录老的ghost管理界面,导出所有blog为一个json

3. ssh 到old_server,同时将old_sever的id_rsa.pub写到new_server的authorized_keys

4.同步数据,主要是图片rsync -auHxv --progress /path/to/ghost/content/images [email protected]_Server_ip:/path/to/migration

5. 部署新服务器

git clone https://github.com/evertramos/docker-compose-letsencrypt-nginx-proxy-companion.git
cp docker-compose-letsencrypt-nginx-proxy-companion/.env.sample docker-compose-letsencrypt-nginx-proxy-companion/.env
./docker-compose-letsencrypt-nginx-proxy-companion/start.sh


git clone https://github.com/LuisArteaga/docker-ghost-mariadb-letsencrypt.git
cp docker-ghost-mariadb-letsencrypt/.env.sample .env
vim .env ##change out the DB_NAME, DB_USER, DB_PASSWORD, DB_ROOT_PASSWORD and *data path (path-to-your)*
docker-compose up -d

6. 拷贝images到新的ghost cp -r /path/to/migration/images /path/to/ghost/content/

7. 重新设置DNS

Done!