Created
September 11, 2014 07:39
-
-
Save philiph/a48f3e79e3eb8190855c to your computer and use it in GitHub Desktop.
Bash script to backup a web front-end project to a timestamped .tar.gz archive.
This file contains hidden or 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/bash | |
if [ $# -eq 0 ]; then | |
echo Expected: 1 arg which is the directory to backup. | |
exit 1 | |
fi | |
project=$1 | |
if [ ! -d "$project" ]; then | |
echo Directory not found: $project | |
exit 2 | |
fi | |
timestamp=$(date +"%Y%m%d-%H%M%S") | |
filename=$project-$timestamp.tar.gz | |
echo Creating archive: $filename | |
tar --exclude='node_modules' --exclude='bower_components' --exclude="build" -czf $filename $project | |
file_size=`du -h "$filename" | cut -f1` | |
echo Archive file size is $file_size. | |
echo Done! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment