Created
September 25, 2013 08:26
-
-
Save crudh/6696672 to your computer and use it in GitHub Desktop.
Directory backup by mail (make sure mailx is installed and in the path).
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
#!/bin/sh | |
# CONFIGURE THIS | |
inputDir=/var/system | |
outputDir=/tmp | |
resultPrefix=system | |
mailSubject="Backup - system" | |
mailBody="Backup - system" | |
mailRecipient=christian@primian.se | |
# DO NOT CHANGE BELOW HERE-------------------------- | |
current=`date +"%Y%m%d-%H%M"` | |
outputFile=$outputDir/$resultPrefix-$current.tar.bz2 | |
# Create the folder | |
mkdir -p $outputDir | |
# Create the archive file | |
tar -c --bzip2 -f $outputFile $inputDir >/dev/null 2>&1 | |
# Mail the file | |
echo "$mailBody" | mailx -s "$mailSubject" -a "$outputFile" $mailRecipient |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment