How To remote backup with rsync

This is probably the simply way to backup data to other server using a secure protocoal an minimum bandwidh.

Note:
BckServer.com - Is the backup server
Server1.com - Is the server you want to backup

Login to the server you want to backup

1. Creating a key with the ssh-keygen utility:
# ssh-keygen -t rsa -N '' (these are two single quotes)

2. Copy RSA encryption key to the backup server:
# scp ~/.ssh/id_rsa.pub username@BckServer.com:keys/server1
# ssh username@BckServer.com mergekeys

Now you can backup a folder without prompting for a password:
# rsync -avz -e ssh /etc/folder username@BckServer.com :folder_on_server1

Rsync configuration Examples:

Back up entire server:
rsync -avz --exclude=/proc -e ssh / username@bckserver.com:folder_on_server1

Back up home directories:
rsync -avz -e ssh /home username@bckserver.com:folder_on_server1

Back up specific users:
rsync -avz -e ssh ~user1 ~user2 ~user3 username@bckserver.com:folder_on_server1

Put it on crontab:
# nano /etc/crontab

Add this line:
13 3 * * * root rsync -avz -e ssh /home username@bckserver.com:folder_on_server1

Save and Exit :)

0 Comments: