Updated dbbackup.sh mail subject

Updated sentora_www-backup
    - Added Logging
    - Added date to file name
This commit is contained in:
Matthew McKinnon 2016-10-07 22:34:04 +10:00
parent 14771ab147
commit 422f0c7944
2 changed files with 19 additions and 4 deletions

View File

@ -14,7 +14,7 @@
# CREATE USER 'dbbackup'@'localhost' IDENTIFIED BY 'PASSWORD'; # CREATE USER 'dbbackup'@'localhost' IDENTIFIED BY 'PASSWORD';
# GRANT LOCK TABLES, SELECT, SHOW VIEW, RELOAD, REPLICATION CLIENT, EVENT, TRIGGER ON *.* TO 'backup'@'localhost'; # GRANT LOCK TABLES, SELECT, SHOW VIEW, RELOAD, REPLICATION CLIENT, EVENT, TRIGGER ON *.* TO 'backup'@'localhost';
SUBJECT="Database Backup Completed $BAKDATE" SUBJECT="$(hostname -f) Database Backup Completed $BAKDATE"
MAILTO="support@comprofix.com" MAILTO="support@comprofix.com"
BAKDATE=$(date +%Y%m%d) BAKDATE=$(date +%Y%m%d)
DBUSER='dbbackup' DBUSER='dbbackup'
@ -38,5 +38,5 @@ for db in $databases; do
done done
cat /tmp/dbbackup.msg | mail -s "$SUBJECT" "$MAILTO" cat /tmp/dbbackup.msg | mail -r "$MAILTO" -s "$SUBJECT" "$MAILTO"
rm -fr /tmp/dbbackup.msg rm -fr /tmp/dbbackup.msg

View File

@ -6,11 +6,26 @@
# This script will: # This script will:
# Backup your public_html folder under /var/sentora/hostdata/DOMAIN_NAME/public_html # Backup your public_html folder under /var/sentora/hostdata/DOMAIN_NAME/public_html
BACKUPDIR='/BACKUP/www/'
BAKDATE=$(date +%Y%m%d)
HOSTDATA="/var/sentora/hostdata"
MAILTO="support@comprofix.com"
SUBJECT="$(hostname -f) sentora sites backup"
WEBPATH=$(find /var/sentora/hostdata/* -maxdepth 0 -type d | awk -F/ '{print $5}') rotate_backups() {
find $BACKUPDIR -type f -mtime +7 -exec rm -frv {} \;
}
rotate_backups
WEBPATH=$(find $HOSTDATA/* -maxdepth 0 -type d | awk -F/ '{print $5}')
for SITES in $WEBPATH; do for SITES in $WEBPATH; do
tar -zcvf /BACKUP/www/$SITES.tar.gz /var/sentora/hostdata/$SITES tar -zcf $BACKUPDIR/$SITES-$BAKDATE.tar.gz -P $HOSTDATA/$SITES >> /tmp/sentora_backup.msg
echo "$SITES-$BAKDATE.tar.gz - $SITES backup successfull" >> /tmp/sentora_backup.msg
done done
cat /tmp/sentora_backup.msg | mail -r "$MAILTO" -s "$SUBJECT" "$MAILTO"
rm -fr /tmp/sentora_backup.msg