Backup with bash and rsync

If you are looking to keep incremental versions of a data set (without using version control such as the git suggestion which would be the other alternate way to do this) consider using rsnap instead of rsync.

It will allow you to take snapshots of a folder or set of files so that you could restore what the whole thing as it was at any given point in time. Instead of saving multiple copies of whole files it should only save the differences between them, saving you the space of having all those duplicates around.

Since it uses rsync to copy the files behind the scenes, you can append rsync options to the end of the command. For example in your situation to keep ten backup copies you could do something like this:

$ rsnap 10 /origin /destination -- --progress --stats \
    --exclude '.thumb' --update --perms

There are the --backup and --suffix options (at least in v3.0.8) but they don't quite accomplish what you want because --suffix is fixed and not auto-incrementing (cp has a nice auto-incrementing backup suffix option). The best I could come up with was using a datetimestamp as the suffix like so:

SUFFIX=`date '+%Y-%m-%d-%H:%M:%S'`
rsync -rh --progress --stats --exclude '.thumb' \
  --backup --suffix="$SUFFIX" \
  --update --perms /origin /destination

I would also look into using git which is an open-source version control software. There's a bit of a learning curve to it, but it sounds like it would be appropriate for what you're trying to do. It also uses ssh, ftp and some other transfer protocols. A good tool for mirroring repositories, tracking changes, etc. It also has great documentation and a very active irc channel (webchat.freenode.net #git)if you get stuck.

Good luck!