Updated rsync command - nasbackup.sh

This commit is contained in:
Matthew McKinnon 2016-03-27 00:13:51 +10:00
parent 6cb8fcdd8c
commit 9c7ee5aa5e

View File

@ -3,9 +3,10 @@
mkdir -p /var/log/nasbackup mkdir -p /var/log/nasbackup
FROMADDRESS=support@comprofix.com MAILTO=mmckinnon@comprofix.com
TOADDRESS=mmckinnon@comprofix.com
SMTP=mail.comprofix.com SMTP=mail.comprofix.com
MAILFROM="$(hostname)@$(dnsdomainname)"
BODSUBJECT="Backup Log `date +%d-%m-%Y`" BODSUBJECT="Backup Log `date +%d-%m-%Y`"
LOGFOLDER=/var/log/nasbackup LOGFOLDER=/var/log/nasbackup
N_DAYS=7 N_DAYS=7
@ -14,17 +15,17 @@ N_DAYS=7
LOG=$LOGFOLDER/backuplog-`date +%d-%m-%Y`.log LOG=$LOGFOLDER/backuplog-`date +%d-%m-%Y`.log
echo "****************************************************************" > $LOG 2>&1 echo "****************************************************************" > $LOG 2>&1
echo "* Start Backup `date` *" >> $LOG 2>&1 echo " Start Backup `date` " >> $LOG 2>&1
echo "****************************************************************" >> $LOG 2>&1 echo "****************************************************************" >> $LOG 2>&1
rsync -urtlPO --delete /data/ /media/nas/ >> $LOG 2>&1 #rsync -urtlPO --delete --exclude 'kvm' /data/ /media/nas/ >> $LOG 2>&1
#rsync -urtlOv --partial --delete /data/ /mnt/nas/ >> $LOG 2>&1 rsync -urtlOv --partial --delete --exclude 'kvm' /data/ /media/nas/ >> $LOG 2>&1
echo "****************************************************************" >> $LOG 2>&1 echo "****************************************************************" >> $LOG 2>&1
echo "* Finished Backup `date` *" >> $LOG 2>&1 echo " Finished Backup `date` " >> $LOG 2>&1
echo "****************************************************************" >> $LOG 2>&1 echo "****************************************************************" >> $LOG 2>&1
sendemail -o tls=no -f "NAS BACKUP <$FROMADDRESS>" -t $TOADDRESS -u "$BODSUBJECT" -m "$BODSUBJECT" -a $LOG -s $SMTP >> $LOG 2>&1 sendemail -o tls=no -f "NAS BACKUP <$MAILFROM>" -t $MAILTO -u "$BODSUBJECT" -m "$BODSUBJECT" -a $LOG -s $SMTP >> $LOG 2>&1
find $LOGFOLDER/* -mtime +$N_DAYS -exec rm {} \; find $LOGFOLDER/* -mtime +$N_DAYS -exec rm {} \;