Skip to content

Instantly share code, notes, and snippets.

@bcalloway
Last active August 29, 2015 13:58
Show Gist options
  • Save bcalloway/9938698 to your computer and use it in GitHub Desktop.
Save bcalloway/9938698 to your computer and use it in GitHub Desktop.
Incremental backup that runs daily
#!/bin/sh
##############################################
# This creates an incremental backup.
# Backups are uploaded to GoogleDrive
# http://tech.rgou.net/en/linux-2/backup-script-on-google-drive-for-linux/
#
# A cron job should run this daily
# 0 2 * * * sh /home/bcalloway/scripts/system_incremental_backup.sh > /dev/null
#
# 2014-04-01 Brandon Calloway
##############################################
# initial GoogleDrive sync
grive
DATE=`date +%Y-%m-%d%n`
# delete incremental backups older than 5 days
find /mnt/GoogleDrive/backups -name "*incr*" -mtime +5 -exec rm {} \;
#create the incremental backup
/bin/tar -cvpzf /mnt/GoogleDrive/backups/$DATE.incr.tar.gz --exclude=/mnt/GoogleDrive --exclude=/home/bcalloway/_backup --listed-incremental=/var/log/usr.snar --one-file-system /
#backup all mysql databases
# /usr/bin/mysqldump --opt --all-databases > /home/bcalloway/_backup/$DATE.mysql.sql
#compress the mysql backup
# /usr/bin/gzip /mnt/beast/_backup/$DATE.mysql.sql
# final Google Drive sync
grive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment