Skip to content

Instantly share code, notes, and snippets.

@sadbox
Last active December 18, 2015 13:49
Show Gist options
  • Select an option

  • Save sadbox/5792952 to your computer and use it in GitHub Desktop.

Select an option

Save sadbox/5792952 to your computer and use it in GitHub Desktop.
tarsnap backup script
#!/bin/bash
logfile="/var/log/tarsnap.log"
email="email@gmail.com"
stuff_to_back_up="/home/ /etc/ /var/www/"
exclude_pattern="Dropbox"
( /bin/echo "$(/bin/date +"%T %F") Starting backup"
/usr/local/bin/tarsnap -c --configfile /usr/local/etc/tarsnap.conf --exclude $exclude_pattern -f "$HOSTNAME-$(/bin/date +%F)" $stuff_to_back_up 2>&1
/bin/echo "$(/bin/date +"%T %F") Backup finished"
) | /usr/bin/tee -a $logfile | /usr/bin/mailx -s "$HOSTNAME backup results" $email
/bin/echo "=================================" >> /var/log/tarsnap.log
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment