Moving a self-hosted Ghost Blog between Servers
I don’t like paying for stuff. I must be an annoying customer. I tend to find a great deal on cloud servers (by great deal I mean free), use that until it runs out and then hunt down another one. For a while I was using Atlantic.net to host this blog, then I was using the free trial period with AWS, then I utilised a student pack thing from Github (yay for still having Uni email) to get $100 credits with DigitalOcean, and now that that has run out I’ve moved over to Azure.
Well, this time I’ve paid for the Azure hosting, but not without a great discount first.
The fun part though comes in trying to migrate my blog between sites. Ghost comes with a great export tool (see Settings > Labs > Export), but that doesn’t cover any images you’ve uploaded. Nor does it cover any code injections you’ve added, like the Disqus comments I’ve put on these posts (yes, there is a code injection part in the Ghost settings, but that’s only for global injections like Google Analytics).
So this is a rough guide to what I do to move between hosts. It’s not automated, because it typically only happens once a year and only takes me about 15 minutes, but hopefully it helps someone in the same situation:
- Use the export tool built-in to the admin portal of the blog (as mentioned earlier) to export the whole blog.
- SSH to the existing server.
- Copy the whole contents of
/path/to/ghost/content/images/
to/tmp/migration
- Use SCP to transfer the
/tmp/migration
folder over to the same location on the new server. - Copy any code injections you have added.
- Install the new Ghost instance in exactly the same way as I did on the old host (you documented the process, right?).
- Go through the web-based setup of the new instance so you can get to the Admin portal.
- Import the export from before into the new instance.
- Move the contents of
/tmp/migration
into/path/to/ghost/content/images/
. - Re-apply your old code injections into the new instance.
- Update DNS, CloudFlare, migrate SSL certificates (if necessary), etc. to finish up.
And if you did it right, you’re new site should happily appear and you can shut down the old one.