Although you may have great version control in place, sometimes stuff gets inadvertently overwritten or messed up…in this case it's always good to do a quick backup before you do anything potentially serious. I've written a little Bash shell hack which I thought might be useful:
In your ~/.bash_profile (or ~/.bashrc if you load that in your .bash_profile) file, add the line:
alias bag='b=$(basename `pwd`);cd ..;tar -cvf $b"_"$(date +'%Y-%m-%d_%H-%M-%S')".tar.gz" "./"$b"/";cd $b'
...then re-load your bashrc by running 'source ~/.bash_profile'
or 'source ~/.bashrc'
.
When you're then in your working directory, simply run 'bag' which will create a time-stamped, gzipped tar file in the directory above the one you're in, containing the contents of the directory you're currently in. Such as: