This shows you the differences between two versions of the page.
daily_and_weekly_backup_with_rsync [2009/06/04 15:09] k2patel created |
daily_and_weekly_backup_with_rsync [2009/10/14 03:22] jt |
||
---|---|---|---|
Line 1: | Line 1: | ||
==== Daily and Weekly Backup with Rsync ==== | ==== Daily and Weekly Backup with Rsync ==== | ||
<code bash | backup-cron.sh> | <code bash | backup-cron.sh> | ||
+ | |||
#!/bin/bash | #!/bin/bash | ||
- | #exclude file will contain strings or directories that should not be archived: | ||
- | #euroco/* | ||
- | #lithium/* | ||
- | #jason/stealthii/* | ||
- | #logs | ||
DAY=$(/bin/date +%m%d%y) | DAY=$(/bin/date +%m%d%y) | ||
DOW=$(/bin/date +%u) | DOW=$(/bin/date +%u) | ||
+ | PATH="/media/backup/stealthsrv" | ||
if [ $DOW == '7' ]; then | if [ $DOW == '7' ]; then | ||
- | /usr/bin/rsync -a --delete --inplace --exclude-from '/root/exclude' /home /media/backup/stealthsrv/weekly-$DAY | + | /usr/bin/rsync -a --delete --inplace --exclude-from '/root/exclude' /home $PATH/weekly-$DAY; |
else | else | ||
- | /usr/bin/rsync -a --delete --inplace --exclude-from '/root/exclude' /home /media/backup/stealthsrv/daily | + | /usr/bin/rsync -a --delete --inplace --exclude-from '/root/exclude' /home $PATH/daily; |
+ | /bin/touch $PATH/daily; | ||
fi | 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> | </code> |