How to Migrate your Ghost install to Coolify
How to migrate your self-hosted Ghost installation to Coolify.
Last month, I wrote a post about how to change the maximum file uploads with WordPress hosted on Coolify. You can read more about Coolify in that article. Today I am going to write about how you can migrate your self-hosted Ghost instance to Coolify.
Create a subdomain on Coolify
For starters, I recommend creating a subdomain to use with your initial Ghost install at Coolify. You then will set up your Ghost service with that subdomain. Anything like ghost.domain.com will work. This way you can test the Coolify Ghost instance first before pointing the main domain to your Coolify server.
Once installed, set it up like any other Ghost install.
Export and download your content
The next thing you will need to do is export your content. The Ghost documentation will explain how to do this. In short, go to Settings and Labs. Then click the Export button (see below) and download. After that, you will need to download your Redirects and Routes if you have any.
Download your theme
After that, you will need to download your theme.
Compress and download your images
Now you will need to SSH to your server. Once there, go to the Ghost content folder
$ cd /var/www/ghost/content
Once there you will need to compress your images folder:
$ zip zip -r images.zip images/*
Since Coolify uses Docker containers, it will be hard to upload the files to Ghost as mentioned in the Docker's documentation. What you will need to do is move it to a public folder that you can access with wget. I put my images.zip with another website.
$ mv images.zip /var/www/activewebsite.com/
If is up to you where you want to move your files.
Migrate all content and theme to Coolify
This next part is simple. Just upload your JSONs for the content, redirects, and routes to the new Ghost installation on Coolify. Once you upload it, you will see the content minus the images.
Then upload the theme. The site should look familiar now.
Log into your Coolify Server
Remember that Coolify uses Docker containers. This means you will need to access your the actual Ghost container.
Now you will transfer images.zip from your current server to Coolify. You can either upload the file to your new server via sFTP, or wget the file from your server Yes, you can fetch your file directly from your container with wget, but I prefer to fetch files into my server first then copy it into the container.
If you do not know how to use wget, just do the following:
$ wget domain.com/images.zip
The file should be stored in your current directly. If you used sFTP, I am assuming you know how to move the file to your current directory. With both options, be sure to check file permissions.
Now you can focus on getting your images.zip file to your Docker container. The first thing you will need to do is find the container ID for your Ghost install:
$ docker ps
You should see something like this:
2e7872g82eef ghost:5.30.0
Now you can copy images.zip to this container doing the following:
sudo docker cp images.zip 2e7872g82eef:/var/lib/ghost/content
This path may be different for some containers so be sure to check your configurations in Coolify. I am planning to use S3 buckets in the future, so this will change for my Ghost instances.
Use sudo if you did not add your username to the Docker group.
After you copied your files over, connect to your Docker container with the following command:
$ sudo docker exec -it <container name> /bin/bash
With the above container ID that would be:
$ sudo docker exec -it 2e7872g82eef /bin/bash
Once inside, update the packages first and then install the unzip package.
$ apt update
$ apt install unzip
Then you need to cd into the content folder and remove the images folder:
$ cd content
$ rm -rf images
Unzip the folder:
$ unzip images.zip
After this, you will need to change ownership to node:
$ chown -Rf node:node images
Check to see if the images load on your Coolify Ghost instance. When you see them, you can remove images.zip and exit the container:
$ rm images.zip
$ exit
Point your domain to Coolify
The last step you need to do is point your main domain to your Coolify server. Wait until it is fully pointed then go to your Coolify Service and Stop the service. You can then change the URL of your main domain. After you saving the domain changes, you can click Deploy and your Ghost site will work with your domain.
You site is now fully migrated to Coolify!
I hope this guide helps those wondering how hard it will be to migrate a Ghost install to Coolify. I still need to re-setup Zapier and Mailgun, but it is a low priority to me at this time.
If you have any comments, please ping me on Twitter or Mastodon.