For those who have read my blog before may notice a change in the blog's theme. This is because today I upgraded my Ghost Docker image from 0.1x to 1.x. Ghost 1.x comes with a default theme I like enough to keep (used to be Atilla Theme). I've been putting this upgrade off for a while due to being a bit worried I'd somehow lose all my themes and blog changes. This was not the case! It's actually quite easy to do. The Ghost update comes with a number of excellent changes which you can read about in their blog.
This blog post will just be how I migrated to Ghost 1.x and will assume you have a similar
docker-compose.yml file as outlined in my previous blogpost.
Content and Settings
The first thing you should do before migrating to Ghost 1.x is back up your files! You do this by navigating to https://blog.yourwebsite.com/ghost/#/settings/labs and finding the Export your content heading and clicking
Export. Save the
.json file somewhere on your local machine.
Export functionality won't save your images, you must do this manually. You can either copy the images to your local machine using
scp or just copy them temporarily somewhere on your VPS. I chose to do the latter. To do this:
- SSH into your machine
- Navigate to your Docker volumes: ie,
- Copy the images:
cp -r ghost/images ./ghost-image-backup
If you used a custom theme, there may be a number of changes that are required before the theme will work with Ghost 1.0. Grab the .zip of your theme and upload to it gscan. Follow all the recommended changes otherwise your theme won't work.
Docker Ghost Volume
Ghost 1.0 uses a different volume structure than 0.1x. As a result, we will either need to delete our old 0.1x volume or change it's name. I chose to change the volume's name just in case I needed to revert to it for some reason. Simply navigate to your Docker volumes and type
cp -r docker-volumes/ghost ghost-old-backup.
Upgrading your Ghost Docker image
First, stop your docker containers by running:
Upgrading the image is quite simple. SSH onto your VPS, run
docker pull ghost:latest. This will grab the latest Ghost image (should be 1.x). We will still have the old Ghost 0.1x image if we want to revert/abort our migration.
Changes to docker-compose.yml
For Ghost 0.1x, the ghost entry in your
docker-compose.yml file might have looked something like this:
ghost: image: ghost container_name: harvey_blog volumes: - ./docker/ghost:/var/lib/ghost expose: - "2368" environment: - VIRTUAL_HOST=blog.yourwebsite.com - LETSENCRYPT_HOST=blog.yourwebsite.com - LETSENCRYPT_EMAILemail@example.com
docker-compose.yml file should look like:
ghost: image: ghost container_name: harvey_blog volumes: - ./docker/ghost:/var/lib/ghost/content expose: - "2368" environment: - VIRTUAL_HOST=blog.yourwebsite.com - LETSENCRYPT_HOST=blog.yourwebsite.com - LETSENCRYPT_EMAILfirstname.lastname@example.org - url=blog.yourwebsite.com - email@example.com
A key difference is in the
volumes entry: /var/lib/ghost -> /var/lib/ghost/content.
Another key difference in Ghost 1.0 is how config is used. In Ghost 0.1x, you may remember all config changes were done in a
config.development/prod.js file in the Ghost volume. Now all config can and should be done through environmental variables. A full list of these variables can be found here.
I've only needed to use 2: url and mail.
Running and moving blog content
Now we need to build our new Ghost container by typing
docker-compose up -d ghost.
Head on over to
Create a new account and then navigate to https://blog.harveydelaney.com/ghost/#/settings/labs. Under the Import content heading, upload the
.json backup file you got from before and click upload.
Now if you navigate to
blog.yourwebsite.com you should see your old content, without images.
Moving the images will involve heading back to your VPS and moving the backed up images to the new Ghost volume:
cp -r ghost-image-backup ghost/images
Reload your blog again and you should see your images. Now just delete all the default entries Ghost has placed in your blog (unless you wish to keep them and make them private).
That's it, you've successfuly migrated to Ghost 1.x. Hope this helped.