I have a server that holds all my backups and I would like to back them up to another server. I was just wondering the best way to do this.

do I setup rsync or use scp? I would also like to keep everything secure and use ssh if possible.

I keep the files under /home/servername/daily


I would recommend using rsync+ssh for security reasons. You can use either pull or push backup. For instance, if you decide to use pull based backup, first generate ssh key on the remote server. You will then pull the files to the remote server from the original backup server.

  1. Remote('another') server: generate private/public key

    ssh-keygen -t rsa -b 2048

    Take the public key generated, say /root/.ssh/id_rsa.pub, to the Backup server.

  2. Backup server - add public key of remote server to the authorized_keys of the backup server.

     cat id_rsa.pub >> /root/.ssh/authorized_keys
  3. Remote server -Test public key ssh connection

     ssh -i /root/.ssh/id_rsa root@backupserver-hostname

    Add the following command to your crontab

    rsync -avz -e "ssh -i /root/.ssh/id_rsa" root@backupserver:/backupdir /thisdir

You can change the username, hostnames, private/public key file names, directories etc. based on your setup.



0 0 * * * rsync -av /home/servername/daily otherserver:/home/servername/dailyreplica

Midnightly crontab to rsync between the two servers.

Requires the root's (or whomever the crontab runs as)'s ssh key putting in the remote host's /home/$user/.ssh/authorized_keys file

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.