Although being a useful option for a programmer (or a writer), it lacks the capability of keeping more backup copies, like a CVS (Concurrent Versions System) where the author can go back in time and find the text file as is was e.g. a month ago (very handy if you want to restore something you have deleted just before one week).
In order to avoid the complexity of a CVS, yet having the option to “travel” back in time, I wrote a small shell script, which I’m running just before my editing sessions. The script looks like this:
mkdir $bdir 2> /dev/null
for a in $*; do
cp -av $a $bdir/$datetime.$a
gzip -9 $bdir/$datetime.*
All it does is to keep a compressed copy of every file you want to edit in a directory named “.backup”, hence I named it “backup2.backup” and I run it as:
backup2.backup *.php *.html
It doesn’t check many things, but I’m using it for some time now. Feel free to enhance it as you like it.
Visit The Light of the LAMP blog for more…