Advertisement
Guest User

rsync hard link backup script

a guest
Mar 19th, 2011
148
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. HOSTNAME=laptop
  2. DATE=`/bin/date "+%Y-%m-%d_%H-%M-%S"`
  3. EXCLUDE=/path/to/backup.exclude
  4. SRC_PATH=/path/to/home/user
  5. DEST_PATH=/mnt/raid5/backups/$HOSTNAME/backup_$DATE
  6. DEST_PATH_DEL=/mnt/raid5/backups/$HOSTNAME/delete_backup_$DATE
  7. CURRENT_PATH=/mnt/raid5/backups/$HOSTNAME/current
  8. HOST=server@backup.internal
  9.  
  10. if /usr/bin/rsync -a --stats --progress --delete --exclude-from=$EXCLUDE --link-dest=$CURRENT_PATH $SRC_PATH $HOST:$DEST_PATH
  11. then
  12.     /usr/bin/ssh $HOST "rm -f $CURRENT_PATH && ln -s $DEST_PATH $CURRENT_PATH"
  13. else
  14.     /usr/bin/ssh $HOST "mv $DEST_PATH $DEST_PATH_DEL"
  15. fi
Advertisement
RAW Paste Data Copied
Advertisement