date=`date "+%Y-%m-%dT%H:%M:%S"`
rsync -aP --link-dest=/target/current '/source/folder' /target/back-$date
rm -f /target/Backups/current
ln -s back-$date /target/current

This is a little script I got off the internet and modified a bit. This script is run in my crontab every 5 minutes. The point of this script is to get a filehistory/time machine-ish thing.

I get a list of snapshots in my backupfolder every five minutes (i.e everytime the script is run)

This thing works great. There is one downside though: If there are no files changed it still runs and creates a fully hardlinked snapshot. Is it possible in any way to modify it so that is only takes an actual snapshot if there is a file changed?

I know it doesn't take up any space, but it clutters my backup folder quite a bit..

  • You send the output of rsync to another text file and parse that. If the output is only about... 5 lines long (whatever the output is from a basic rsync with no changes) then just delete the destination you just created. My advice is to reduce the number of times you back up during the day. rsync can never be a time machine replacement. Perhaps once an hour would suffice? Additionally, you can use a diff command to see if there's anything that's changed. Yet another option is use rsync and -n/--dry-run to see if a full sync needs to happen. – UtahJarhead Dec 27 '13 at 15:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.