| backups using rsync+ssh how-to simplified |
a quick how to on rsync over ssh all automated using ssh keys. got all of this info over the net, but this is simplified might be of use to someone? not really linux specific, either. Also, authorized_keys2 is ssh 2 specific and the newer openssh servers/clients can read both authorized_keys and authorized_keys2 files.
- make sure ssh and rsync are installed on both computers
- ssh-keygen -t dsa as root
- choose a location other than /root/.ssh/id_dsa (ex. /root/.ssh/remotehost.id_dsa)
- enter a BLANK passphrase
- write a file called
config inside /root/.ssh/ with options like these
Host remotehost
User root
Compression yes
Protocol 2
RSAAuthentication yes
StrictHostKeyChecking no
ForwardAgent yes
ForwardX11 yes
IdentityFile /root/.ssh/remotehost.id_dsa
- copy the /root/.ssh/remotehost.id_dsa.pub file and paste the file in or at the end of the remotehost's /root/.ssh/authorized_keys2 file
- test if you can login using ssh remotehost ; if you can't login, add the -v flag and check permissions for /root/.ssh on both computers (should be chmod 700 with the files inside the directory 600). Also, check the sshd_config file to see if root is permitted to login.
- now you can rsync a local directory onto the remotehost! here's an example:
/usr/bin/rsync -e ssh -avzp --exclude "*.journal" --exclude "dnscache/" --exclude "dnscachex/" --delete /home remotehost:/var/backups/mycomputer/ which will archive and mirror /home onto the remotehost's /var/backups/mycomputer directory and keep all the permissions. Slashes matter, this works for me though. Note that *.journal are the journal files on ext3 partitions and don't need to be copied and the --delete flag can be omitted in case you want to keep old file that have been deleted archived on the remotehost side permenently.
- place the above command inside a shell script and place in /etc/cron.daily
|
|