Last active
August 29, 2015 13:56
-
-
Save adionditsak/8843493 to your computer and use it in GitHub Desktop.
Backup valuable content swiftly without much struggle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
#### DEPENDENCIES: mutt | |
#### VARS | |
[email protected] | |
DATE=$(date +%Y-%m-%d) | |
LOCAL_BACKUP=/path/to/backup | |
LOCAL_ARCHIVE=$HOME/backup-${DATE}.tar.gz | |
#### FUNCTIONS | |
function main() { | |
archive | |
delete_locally | |
} | |
function archive() { | |
echo "Archiving your files from ${LOCAL_BACKUP}- " | |
tar -czvf ${LOCAL_ARCHIVE} ${LOCAL_BACKUP} | |
echo "Done" | |
} | |
function mail() { | |
echo "Sending e-mail with backup ${LOCAL_ARCHIVE} - " | |
if [ -f ${LOCAL_ARCHIVE} ]; then | |
echo "Backup of files from ${DATE}" | mutt -s "BACKUP OF: ${LOCAL_ARCHIVE}" -a ${LOCAL_ARCHIVE} -- ${MAIL} | |
echo "Done" | |
else | |
echo "Could not find archive at ${LOCAL_ARCHIVE}" | |
exit | |
fi | |
} | |
function delete_locally() { | |
echo "Removing ${LOCAL_ARCHIVE} locally - " | |
rm -f ${LOCAL_ARCHIVE} | |
echo "Done" | |
} | |
#### INIT | |
main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment