yet another backup script

After reading the excellent Easy Automated Snapshot-Style Backups with Linux and Rsync, I deicided to make a new backup script for my home directory that would keep the last 9 incremental snapshots.

Here is the resulting script:

if [ -n "$1" ] ; then

if [ -n "$2" ] ; then

LINKTO=--link-dest=$TO/`basename $FROM`.1
OPTS="-Ca --delete --exclude-from=$FROM/bin/rsync-excluded -delete-excluded"

find $TO -maxdepth 1 -type d -name '*.[0-9]'| sort -rn| while read dir
	this=`expr match "$dir" '.*\([0-9]\)'`; 
	let next=($this+1)%$NUMBER_OF_BACKUPS;
	if [ $next -eq 0 ] ; then
		 rm -rf $dir
		 mv $dir $basedirname.$next
rsync $OPTS $LINKTO $FROM/ $TO/`basename $FROM.0`

It would be nice to extend it to add the possibility to create an unlimited number of incremental backups.

P.S. In the plans: a detailed explanation of the payslip calculation in Belgium

Java enums suck (as if everyone disagreed)

Java enums are translated by the compiler into a class that contains the enum elements as public static final fields.

If we put specific code into the enum elements, these fields become inner classes. (So that they can store code for each element)

One non-obvious consequence of this approach is that

Myenum.MyElement.getClass().getName() may return either Myenum or Myenum$n where n is an ordinal number of the element, depending on whether the element has associated code or not.

Software shapes life

Just another story I presented on a few occasions already.

Belgium has a very developed temporary job market. One particular feature of temporary contracts, also called interim contracts is that they are made for the period of 1 week and then renewed as needed. The 1-week length is perceived as a tradtion not a requirement, as the only legal limit to interim contracts is 6 months. Only few people know that this tradition comes from the limitation of the interim mangement software called ISI wich is still used by ~90% of all interim offices in Belgium. The original ISI software allowed to make contracts and invoices for 1 week at most, this forcing all the interim market to live by 1-week cycles.