A Tiny Backup Script with Rsync

This script lets you easily mirror a local directory to foreign computers that have rsync installed - securely via ssh. It assumes you have already set up a public key authentication with those servers. (Have a look at ssh-keygen and ssh-copy-id)
# (c) 2008 linux-tipps.blogspot.com

# the base path
DIRS="Desktop Documents"
# you can also use absolute paths

RSYNC="rsync -av --progress -e ssh"
# add -z for compression

ssh-add -l || ssh-add
# this adds ssh private keys if not added already
# for cron scripts use keychain instead:
# source ~/.keychain/*-sh
# see here for more

cd $FROM

$RSYNC -z $DIRS djtm@server1:/some/path/Backup/ &

$RSYNC $DIRS djtm@server2:/some/path/Backup/ &

wait && echo Sync Done. || echo Sync Failed or Aborted.

No comments:

Post a Comment

I appreciate comments. Feel free to write anything you wish. Selected comments and questions will be published.