Using rsync on an app instace

Hey guys , am really confused about how ssh and remote commands work in fly

# this will register a ssh key with your local agent (if you haven't already)
flyctl ssh issue --agent

# proxies connections to a fly VM through a Wireguard tunnel
flyctl proxy 10022:22

# run in a separate terminal to copy the pb_data directory from the remotely 
# (to restore from local -> remote you can reverse the arguments)
scp -r -P 10022 root@localhost:/pb/pb_data  /your/local/path/where/to/copy/pb_data

What’s the difference between Trying the above and using fly ssh console
can i run SCP or rsync using fly ssh console ?

I managed to get the above first code snippet working but doing LS in fly ssh console showed no changes

The command also wouldn’t work the second time
What am I doing wrong and is there a better way to send files back and forth to the app instance?

What you are doing looks fine.

The command you posted is copying from the remote VM to your local filesystem, so to check if it succeeded you should run ls locally (not using fly ssh console).

(If you want to upload files from your local filesystem to the remote VM, you need to swap the arguments as the comment in your post says: scp -r -P 10022 /your/local/path root@localhost:/pb/pb_data)

scp prints the names of the files that it copies, so you should check its output; if there is no output, it’s probably because you are copying an empty directory.

To answer your specific questions:

fly ssh console automatically issues a certificate and creates a WireGuard tunnel, but it’s only for running commands over SSH (not for copying files).

Not really (you could try using rsync’s -e/--rsh option or scp’s -S option, but I wouldn’t recommend it).

However there is fly ssh sftp shell, if you want to use an SFTP-like interactive shell. Personally I think scp/rsync with a manual certificate and proxy as you are doing is easier (one downside is that this requires scp/rsync to be installed on the remote VM).

1 Like