Skip to content

Instantly share code, notes, and snippets.

@wabarr wabarr/
Last active Aug 29, 2015

What would you like to do?
shell script to check if sqlite database has changed, and to email the backup file if so
#get the current md5sum, and use awk to strip out filename, which is reuturned as well
#note, this assumes that md5sum_of_database_at_last_backup.txt exists and contains the hash of db at last backup
#currently no error checking
currentMD5=$(md5sum test.db | awk '{print $1}')
lastMD5=$(cat /home/user/md5sum_of_database_at_last_backup.txt)
if [ "$currentMD5" == "$lastMD5" ]
echo | mutt -s "database has not changed since last backup"
#update the database
echo $currentMD5 > /home/user/md5sum_of_database_at_last_backup.txt
#send db as email attachment
echo | mutt -a /home/user/test.db -s "daily database backup"
unset currentMD5
unset lastMD5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.