- rsync
- openssh
- cron (or vixie-cron)
Use ssh-keygen command as follows:
$ ssh-keygen -t dsa
Next make sure you have correct permission on .ssh directory:
$ cd
$ chmod 755 .ssh
$ scp ~/.ssh/id_dsa.pub user@jerry:.ssh/authorized_keys
Login to your remote server and make sure permissions are set correct:$ chmod 600 ~/.ssh/authorized_keys
2.Create the sricpt
The script should like this:#!/bin/sh
RSYNC=/usr/bin/rsync
SSH=/usr/bin/ssh
KEY=/home/thisuser/cron/thishost-rsync-key
RUSER=remoteuser
RHOST=remotehost
RPATH=/remote/dir
LPATH=/this/dir/
$RSYNC -az -e "$SSH -i $KEY" $LPATH $RUSER@$RHOST:$RPATH
3. put in cron
When I get the script running successfully, I use 'crontab -e' to insert a line for this new cron job:
0 5 * * * /home/thisuser/cron/rsync-remotehost-backups
for a daily 5 AM sync, or: 0 5 * * 5 /home/thisuser/cron/rsync-remotehost-backups
for a weekly (5 AM on Fridays). Monthly and yearly ones are rarer for me, so look at "man crontab" or here for advice on those.
0 comments:
Post a Comment