Wednesday, September 9, 2009

rsync

SkyHi @ Wednesday, September 09, 2009
#!/bin/sh
backupSystemName=backupserver
backupSystemUser=backupuser
# rsync
echo "[backup/thedump] $HOSTNAME - `date` " > /tmpdirectory/.output
echo "------------------------------------" >> /tmpdirectory/.output
echo "directory: /etc" >> /tmpdirectory/.output
rsync -v -r -u -L --bwlimit=200 --delete --delete-excluded -e ssh -z /etc $backupSystemUser@$backupSystemName:/backupdirectory/$HOSTNAME >> /tmpdirectory/.output
echo "------------------------------------" >> /tmpdirectory/.output
echo "directory: /home" >> /tmpdirectory/.output
rsync -v -r -u -L --bwlimit=200 --delete --delete-excluded -e ssh -z /home $backupSystemUser@$backupSystemName:/backupdirectory/$HOSTNAME >> /tmpdirectory/.output
echo "------------------------------------" >> /tmpdirectory/.output
echo "directory: /usr/local" >> /tmpdirectory/.output
rsync -v -r -u -L --bwlimit=200 --delete --delete-excluded -e ssh -z --exclude apache/logs/ /usr/local $backupSystemUser@$backupSystemName:/backupdirectory/$HOSTNAME >> /tmpdirectory/.output
echo "------------------------------------" >> /tmpdirectory/.output
echo "directory: /root" >> /tmpdirectory/.output
rsync -v -r -u -L --bwlimit=200 --delete --delete-excluded -e ssh -z /root $backupSystemUser@$backupSystemName:/backupdirectory/$HOSTNAME >> /tmpdirectory/.output
echo "------------------------------------" >> /tmpdirectory/.output
echo "directory: /var" >> /tmpdirectory/.output
rsync -v -r -u -L --bwlimit=200 --delete --delete-excluded -e ssh -z --exclude /var/mail/ --exclude /var/log/ --exclude /var/spool/ /var $backupSystemUser@$backupSystemName:/backupdirectory/$HOSTNAME >> /tmpdirectory/.output
echo "------------------------------------" >> /tmpdirectory/.output
echo "complete." >> /tmpdirectory/.output
mail -s "[backup/thedump] $HOSTNAME - `date`" sysadmin@server < /tmpdirectory/.output