This shows you the differences between two versions of the page.
Both sides previous revision Previous revision | |||
daily_and_weekly_backup_with_rsync [2009/10/14 03:22] jt |
— (current) | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ==== Daily and Weekly Backup with Rsync ==== | ||
- | <code bash | backup-cron.sh> | ||
- | #!/bin/bash | ||
- | |||
- | DAY=$(/bin/date +%m%d%y) | ||
- | DOW=$(/bin/date +%u) | ||
- | PATH="/media/backup/stealthsrv" | ||
- | |||
- | if [ $DOW == '7' ]; then | ||
- | |||
- | /usr/bin/rsync -a --delete --inplace --exclude-from '/root/exclude' /home $PATH/weekly-$DAY; | ||
- | else | ||
- | /usr/bin/rsync -a --delete --inplace --exclude-from '/root/exclude' /home $PATH/daily; | ||
- | /bin/touch $PATH/daily; | ||
- | fi | ||
- | |||
- | for i in $(/usr/bin/find $PATH -maxdepth 1 -type d -mtime +30); | ||
- | do | ||
- | echo "Removing $i: older then 30 days" >> /var/log/backup.log; | ||
- | /bin/rm -Rf $i; | ||
- | done | ||
- | </code> |