Setup Full Server Remote Backup using rsync via SSH

Full Server Remote Backup using rsync via SSH


Login to your server via ssh which you want to take backup. Login as root user.

Check the rsync operation in your server. This time it will ask for the password.

root@server [~] # rsync -avz -e ssh /test root@<BackupServerIP>:/backup/

You have to follow Step2 to make key based ssh login from a particular IP.


In order to run the cronjob for creating backup, you need to configure rsync over ssh that doesn’t ask for a password.

Create an RSA encryption key for use with the SSH transport.

root@server [~] # ssh-keygen -t rsa -N ''

Use ssh-copy-id, to copy the public key to the remote host(Backup server).

root@server [~] # ssh-copy-id -i ~/.ssh/ root@<BackupServerIP>

This time it will ask for the ssh password for the root user to copy the key.


Test rsync over ssh without password

root@server [~] # ssh <BackupServerIP>

Now, you should be able to ssh to remote host without entering the password. If it is working fine perform a test rsync operation. It will not ask for password this time.

root@server [~] # rsync -avz -e ssh /test root@<BackupServerIP>:/backup/


If Step3 passed the tests with rsync, you have to make a cronjob to run the backup periodically.

root@server [~] # crontab -e
0 1 * * * rsync -avz --exclude=/proc --exclude=/sys --exclude=/dev -e ssh / root@<BackupServerIP>:/backup

The above cronjob will take backup of the entire server excluding /proc, /sys and /dev direcories. The above cronjob will run on every day at 1AM.


This entry was posted by Unknown. Bookmark the permalink.