I wanted to have a little backup script running as a cronjob that efficiently generates a rotating backup for each day of the week.

I came up with a script, that uses rsync together with its --link-dest parameter that does exactly this:

[gist id=3051628]

You just have to give a list of folders to backup to the BACKUPPATHS variable together with a target path for each folder to backup in the TARGETPATH variable. The --link-dest parameter causes rsync to create hard links instead of copies of a file, if no changes were made to that file. This does not occupy additional hard disk space.