The Autodidacts

Exploring the universe from the inside out

How to Backup Ghost on with Rsync

This is yet another small companion piece to my Ghost on Fly tutorials.

In my last tutorial in the series, I showed how to back up your Ghost blog hosted on over SFTP.

SFTP does the job, but transferring all those images and files every time is a waste of bandwidth — and pig-slow.

Rsync is an amazing command line file synchronization utility, and a much better tool for the job.

It took me a while to figure out how to scp file to and from Fly VM persistent volumes. Once I’d figured that out[1], swapping scp for rsync was simple.

Here’s how to back up your blog in seconds, rather than minutes, without sending eight years worth of uploads over the wire each time.

In one terminal, run:

flyctl proxy 10022:22

In another, SSH in:

fly ssh console

Install rsync on the remote (which is running Alpine Linux, if you followed my tutorial):

apk add rsync

Back on your local machine, run:

ssh-agent bash
ssh-keygen -f "/home/USERNAME/.ssh/known_hosts" -R "[localhost]:10022"
flyctl ssh issue --agent

After that, run the backup! To rsync Ghost’s content files from the persistent volume:

rsync -aviz -e 'ssh -p 10022' root@localhost:/var/lib/ghost/content/ .

I’m using the -a (--archive) flag with -z (--compress), with -v (--verbose) -i (--itemize-changes).

It probably doesn’t hurt to run it with the --dry-run flag first, to make sure everything’s working as expected. 😇

In the unlikely event that you found this tutorial so helpful and thrilling that you’d like to support me, you can sign up for Ghost(Pro) with my referral link, or buy one of my premium themes Or, if you’re like me, host your blog for free using one of my free themes instead, while thinking grateful thoughts.