Ghost (blog) migration to 1.0
Introduction:
It's been some time since Ghost 1.0 was released, and I've been putting off this day for a while. Essentially the migration strategy I was trying to use wasn't working in the slightest and moving everything seemed to be a bit of a nightmare. Whether the migration document has improved on the ghost website, or whether I was just in the right mood to do it properly I don't know! But here's what I did...
Implementation:
The actual migration guide is here: https://docs.ghost.org/docs/migrating-to-ghost-1-0-0
I've taken some snippets from this article and included them here.
I'm using docker, so I did a few things differently.
First I'll show the two docker-compose syntaxes:
Old:
ghost:
image: ghost:0-alpine
restart: always
volumes:
- /path/to/config:/var/lib/ghost
environment:
- NODE_ENV=production
- GHOST_CONTENT=/var/lib/ghost
New:
ghost:
image: ghost:alpine
restart: always
volumes:
- /path/to/1.0/config:/var/lib/ghost/content
environment:
- url=https://blog.dchidell.com/
So, pretty much the same. The only real difference is that we have no environment variables on the new one (I don't need them - not quite sure what they're doing there in the old oneto be honest, it was a while ago I put it together. I've also added the 'url' parameter to the environment variables. This is because by using our above configuration ghost will actually hold the primary configuration file OUTSIDE of our content directory. This means any config changes have to be made using environment variables. Information on these can be found here: https://docs.ghost.org/v1.0.0/docs/config Note: They are case sensitive!
First thing to note is that I didn't copy anything originally from the old to the new, I simply created the new container and went from there.
-
Create the new container - and keep the old one running! I actually just used the standard docker run command with some of the parameters highlighted above in the compose files to create an initial 'provisioning' container. I used an external port mapping so I could access both blogs at the same time without adding the new one to the loadbalancer.
-
Create the .json backup of the blog content. We'll use this to import everything later on. Navigate to yourdomain.com/ghost/settings/labs/ (the settings > labs page in Ghost-Admin) and click on the Export button.
-
Deploy a new ghost instance, this should be completely clean with nothing in the shared directory, Ghost will create all the new folders etc itself.
-
On your new site import navigate to yourblogdomain.com/ghost/#/settings/labs (the settings>labs page in Ghost-Admin). Click Choose file and select the JSON export file created in [step 2] then click on the Import button.
-
Copy over the image content: You need to copy/move your images from your existing directory
/content/images to the new blog directory /content/images. Remember just to copy the content folder. -
Give the container a restart and everything should be as expected! It's very easy to move the image content into the wrong place so if it doesn't work properly check where the content has been moved to.
-
You're done! Check that all URLs are updated and working. I had to change a few things inside the config pages to reflect my blogs URL, as well as delete some of the pages that were there by default.