How to Backup Your Ghost Site on Fly.io using SFTP
This is a small companion post to my Ghost on Fly tutorials, covering how to keep your site backed up.
The normal way to backup a Ghost site hosted on a VPS is to run
ghost backup. However, since we didn’t install Ghost on Fly using the Ghost CLI, the
ghost backup command isn’t conveniently available.
So, this is how I backup my Ghost sites hosted on Fly.io.
First, following the steps outlined in Ghost’s docs page on manual backups, export the things that can be exported from the admin panel (posts, members, routes, etc).
Then, open an SFTP shell over SSH using the Fly CLI (which you should already have installed, from when you deployed your site):
flyctl ssh sftp shell -r -a APPNAME
At the prompt, type:
get /var/lib/ghost/content/ GHOST-CONTENT-BACKUP-YYYY-MM-DD
YYYY-MM-DD to the current date. I haven’t yet taken the time to figure it out how to automatically insert the date.)
This will create a .zip file in your current working directory with images, themes, file uploads, logs, and so forth. (You could probably ignore the logs, if you want to save space.) It will also likely include backup JSON files and routes, but I wouldn’t rely on the freshness of the data.
It takes a while, so just let it chug along. In the future, I’d like to use be using
rsync, for speed and efficiency. (Rsync is amazing!) When I get around to getting
rsync working with Fly, I’ll write another tutorial or update this one. In the meantime, a slow backup is better than no backup.