Previously this blog is using a pretty old version of Ghost 0.11, which was released back in 2016 and the tool Ghost-CLI was not released yet. This blog is hosting on the DigitalOcean using Ubuntu 14.04, so I decided to migrate it to a new Droplet with Ubuntu 20.04 and upgrade Ghost 0.11 to Ghost 4.x and use the tool Ghost-CLI to manage Ghost.
Back up your data
The first step is to back up your data by copying everything under the ghost directory(e.g. /var/www/ghost) to another directory or your local machine. As I have to migrate it to another VPS, I download everything from the server via shell access.
Once you’re logged in to your server,
cd to the parent directory of your ghost directory:
And then zip the ghost directory with all its contents:
zip -r ghost.zip ghost/*
Now we need to get that zip file from your server onto your local machine:
scp user@ip-of-your-server:/var/www/ghost.zip ~/Documents/ghost.zip
Export your content
Log in to Ghost admin, and navigate to the Labs, and you should see Export your content.
Click on the export button and it will download a json file named something like your-blog.ghost.2022-05-01.json containing nearly everything except the images.
If you have Ghost 4.x installed and try to import the content using the above json exported by Ghost 0.11, you would see the error message like this "Import failed Please install Ghost 1.0, import the file and then update your blog to the latest Ghost version", because the json format is v1 and is not compatible with new version v2 and we have to transform it to v2.
Transform exported json to v2
First, we have to install Ghost 1.x to transform the json, and I did it on my Mac locally instead to avoid extra setup.
Run the following command to install Node.js version (10.24.1) using Homebrew
brew install node@10
and then install Ghost-CLI 1.11.0
npm install -g firstname.lastname@example.org
and then install Ghost v1.26.2
ghost install local --v1
If the Ghost was installed successfully, you should be able to access http://localhost:2368/ghost/. Log in to Ghost admin, and navigate to the Labs, click on Choose File in the Import content section, and choose the json you downloaded before, and click on Import button. You should see the below message if it is imported successfully.
Click on the export button again to download the transformed json.
Now you can upgrade the Ghost to 4.x on you server by running the below command:
npm install -g ghost-cli@latest
and then import the transformed json.
Upload your images
The final step is to upload your images. Unzip the file ghost.zip you backed up before, and go to directory content and run the following command to upload the images to your server:
scp -r images user@ip-of-your-server:/var/www/ghost/content
Now we are all set.
Hope it helps,