Rsync backup

A simple tutorial on how to synchronise two directories with Rsync via SSH.

Thursday April 17th, 2008

Work in progress! This is not the final text yet.

syntax:

rsync -ruvz -e ssh user@host:/remote/dir /local/dir/

ssh key exchange, chose no passphrase

ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/user/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/user/.ssh/id_rsa.
Your public key has been saved in /home/user/.ssh/id_rsa.pub.
The key fingerprint is:
27:4c:6d:cf:4c:c8::13:22:70:f6:61:a8:35:cf:a0:23 user@localhost

~/.ssh/id_rsa.pub

ssh-rsa G9BjydOJPGH0RFNAy1QqIWBGWv7vS5K2tr+EEO+F8WL2Y/jK4ZkUo+n7DWQV
AAAAB3NzaC1yc2EAAAABIwAAAIEArkwv9X8eTVK4F7pMlSt45pWoiakFkZMwOHsRQgoi
ijcS3LvtO+50Np4yjXYWJKh29JL6GHcp8o7+YKEyVUMB2CSDOP99eF9g5Q0d+1U2WVdB
WQM= user@host

Copy to remote server's ~/.ssh/authorized_keys

crontab script:

#!/bin/sh 
rsync=/usr/bin/rsync 
ssh=/usr/bin/ssh 
ruser=user 
rhost=host 
rdir=/remote/dir 
ldir=/local/dir/ 

$rsync -ruvz -e $ssh $ruser@$rhost:$rdir $ldir 

crontab (01:00):

crontab -e

0 1 * * * rsync_backup.sh > /var/log/rsync_backup.log

crontab -l

Work in progress! This is not the final text yet.

Copyright © 2002 - 2010 ajira.eu; All rights reserved.