serverscripts/nasbackup.sh

30 lines
1012 B
Bash
Raw Normal View History

2014-11-20 23:45:20 +10:00
#!/bin/bash
#apps backup downloads fun games movies mp3s tvshows wow
2014-11-21 00:56:04 +10:00
mkdir -p /var/log/nasbackup
2014-11-20 23:45:20 +10:00
FROMADDRESS=mmckinnon@comprofix.com
TOADDRESS=mmckinnon@comprofix.com
SMTP=mail.comprofix.com
BODSUBJECT="Backup Log `date +%d-%m-%Y`"
2014-11-21 00:56:04 +10:00
LOGFOLDER=/var/log/nasbackup
N_DAYS=7
2014-11-20 23:45:20 +10:00
2014-11-21 00:56:04 +10:00
LOG=$LOGFOLDER/backuplog-`date +%d-%m-%Y`.log
2014-11-20 23:45:20 +10:00
echo "****************************************************************" > $LOG 2>&1
echo "* Start Backup `date` *" >> $LOG 2>&1
echo "****************************************************************" >> $LOG 2>&1
2014-11-26 00:22:09 +10:00
rsync -rltDyzPOu --delete /data/ /mnt/nas/ >> $LOG 2>&1
2014-11-20 23:45:20 +10:00
echo "****************************************************************" >> $LOG 2>&1
echo "* Finished Backup `date` *" >> $LOG 2>&1
echo "****************************************************************" >> $LOG 2>&1
sendemail -f "NAS BACKUP <$FROMADDRESS>" -t $TOADDRESS -u "$BODSUBJECT" -m "$BODSUBJECT" -a $LOG -s $SMTP >> $LOG 2>&1
2014-11-21 00:56:04 +10:00
find $LOGFOLDER/* -mtime +$N_DAYS -exec rm {} \;