How to backup data on your Fly app's persistent volume using rsync

I wanted to expand on my reply to How to copy files off a VM - #24 by Curiositry – in which I finally figured out how to use scp to backup data (in this case, the content of a Ghost blog) – now that I’ve figured out how to use rsync with fly. The steps are basically identical:

# In one terminal
flyctl proxy 10022:22

# In another, SSH in
fly ssh console
# Install rsync on the remote (alpine linux)
apk add rsync
# To use scp, you'll also need to install scp, which is part of openssh
# (I don't think this is needed for rsync, but I might have still had it installed from when I was using scp, so I'm including it.)
apk add openssh

# Back on your local machine, these commands seemed to be necessary in order for flyctl ssh issue --agent to work:
ssh-agent bash
ssh-keygen -f "/home/USERNAME/.ssh/known_hosts" -R "[localhost]:10022"
flyctl ssh issue --agent

# After that, I could rsync 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). Probably doesn’t hurt to run it as a --dry-run to make sure everything’s working as expected :innocent:


Now a blog post, for permanence and discoverability:

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.