Skip to content

Instantly share code, notes, and snippets.

@danmilleruk
Created March 10, 2013 12:24
Show Gist options
  • Save danmilleruk/5128362 to your computer and use it in GitHub Desktop.
Save danmilleruk/5128362 to your computer and use it in GitHub Desktop.
Best path for this being /scripts/backups/backup_web.sh
#!/bin/sh
# Web backup script
# by Dan Miller
# http://www.danmiller.co.uk
### Begin Configuration ###
EMAIL="you@email.com" # Email address to send the backup report to. (sendmail must be installed)
WEBPATH="/data/www" # No trailing slash
DESPATH="/data/dropbox/Server Backups/www" # Destination path to perform the rsync
LOG="/scripts/backups/logs/www.log" # Log (can be located anywhere valid)
HOSTNAME=`/bin/hostname`
TYPE=WEB
DAY=$(date +%A)
### End Configuration ###
# Remove the existing log file
rm $LOG
echo "This is the $TYPE backup report for $HOSTNAME\n\n" >> $LOG
echo "======================================================\n" >> $LOG
rsync -arv --progress --delete --exclude '*.log' $WEBPATH/* "$DESPATH" >> $LOG
echo "\n======================================================\n\n" >> $LOG
echo "Sent using the magical powers of Deehem's Backup Script." >> $LOG
# Now we use sendmail to send the backup report.
/usr/bin/mail -s "$TYPE Backup Report ($DAY) for $HOSTNAME" "$EMAIL" < $LOG
# EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment