I found the instructions on how to migrate self-hosted Ghost from one host to another quite lacking. It took a lot of tinkering to get it to work properly. And I still don’t quite understand why just picking up an install folder and database dump on one host and dropping it into the new doesn’t work. But I guess this isn’t LAMP-stack PHP-based simplicity.
So. Here goes.
Caveat
This post is going to assume a lot of knowledge, and doesn’t go into detail about specific steps. More about what steps are required than exactly how to do them. It’s also going to assume that your server is ready for running Ghost – all the prerequisites are there including ghost-cli. This will most likely be taken care of in Step 3 if it isn’t ready for running Ghost, but it’s not going to be covered here.
There will be downtime.
Caveat emptor. YMMV etc.
Step 1 – Export the Ghost data from existing host
Export all members to a CSV.
Export the site details to a JSON – on older installs this is under Settings -> Labs, in the newer ones, it’s under Settings -> Import/Export.
Grab a copy of the config file config.production.json
Step 2 – Update DNS
Point your domain to your new server IP. Don’t forget to do IPv6 too. Wait for propagation to happen. 10 seconds or an hour. Who knows! DNS is magic.
Step 3 – Install Ghost on the new host
This is done with the ghost-cli command ghost install in the directory that you want it to install. Once the installation process is complete, log in to the site, create your user and do all the basics. Delete the default posts and other users.
Step 4 – Migrate images over from the old host to the new
rsync is your friend here. Something like:
rsync -r /var/www/ghostfolder/content/images/ username@host2.example:/var/www/ghostfolder/content/images/
will swiftly move your images over.
Step 5 – Run ghost doctor and fix file permissions
Step 6 – Import members CSV
Step 7 – Import site content JSON
Step 8 – Config file
Add the SMTP settings from config.production.json to your new config file on the new host