keeping old revisions


One might be to lazy to set up or use a revision control system like CVS, SVN or git for small projects or when working on 2-3 simple files.

This script creates a directory “backup”, and places there a archive of the files in the current directory (not recursive) with an increasing number.

e.g. you start it in a Folder “Bsp-3″, it will create “backup/Bsp3-1.tar.bz2″, next time “Bsp3-2.tar.bz2″, etc.
Also cleans up duplicates, so you cannot call it too often!

Small, clean, easy. I love it!

backup-point.sh

DIRNAME=$(basename $PWD)
EXT=tar.bz2
mkdir -p backup
cleanup_unneeded(){
cd backup
FILES=*.tar.bz2
UNIQ=$(md5sum $FILES|sort|uniq --check-chars=32 | cut -d ' ' -f 3-);
for i in $FILES
do
if ! echo "$UNIQ" | grep -wq "$i"
then
echo "deleting unnecessary $i."
rm "$i"
fi
done
cd ..
}
cleanup_unneeded
for((i=1;i<200;i++)); do
FILENAME="backup/$DIRNAME-$i.$EXT"
if ! test -f "$FILENAME"; then
find  -maxdepth 1 -type f|xargs tar -cjf "$FILENAME"
echo "backup-point $i made."
cleanup_unneeded
exit
fi
done
echo '200 points reached! Clean up a bit?'

,

  1. #1 by panzi on August 15th, 2008

    Nice, but I can’t see a reason why anyone should be to lazy to type:

    hg init .

    And every now and then:

    hg ci

    This way you have a full blown hg (mercurial) repository with revert and all. You can use “hg serve” or “hg view” to browse your history and you could even push to sharesource.org when your 2 or 3 files become a real project. ;)

    Some of the complang servers got hg installed, so you can use it to submit your work and collaboratively work with your team mates in lectures like “Fortgeschrittene Funktional Programmierung” (hg needs no hg server running, it just needs a ssh connection to a peer where hg is installed). ;)

(will not be published)

  1. No trackbacks yet.