backups using rsync over ssh

Hi all,

Just wondered if someone with more linux experience than myself could give me a little help.

I’m backing up all my Virtualmin domains nightly with a scheduled back, and i want to rsync them to another server after that has completed. I know i need to setup rsa keys so that ssh can login without a password but i’m kind of confused over which user gets the key.

Here is the command that works manually.

rsync -ave ssh /root/backups/

As Virtualmins backups are owned by root, i need to run rsync as root in order to read the files, but i want to access the remote machine as “backupuser”… I’ve tried creating keys for root, but this doesnt seem to work, do i need to create the backupuser account locally, even if i’m rsync’ing as root.

I’m sure this should be simple, once you know how :slight_smile:

Cheers, Chris

Hey Chris,

You have several options, depending on which machine is more “trusted”. But I think the best bet, and what you’re specifically describing, is this:

Create a public/private key pair for root on your Virtualmin machine using ssh-keygen.

Copy the public key (/root/.ssh/, probably) into a file called authorized_keys on the backup machine in the directory /home/backupuser/.ssh (make sure it is owned by backupuser).

This should allow you to ssh to the backup machine as backupuser when logged in as root on the Virtualmin machine without a password. Now your script, when run as root, will be able to run without a password.