I want to roll my own little backup script that works in a similar way as Apple's "Time Machine". For the most frequent backups, i.e. every hour or so, I want to use rsync. However, my entire approach depends on the way rsync treats files that have been modified. I couldn't find any answer to my question in the man pages, nor on the rsync website, nor on google.
This is my question: if rsync updates a file that has been modified, does it change the outdated file in-place, or does it unlink the old file and add a new directory entry for the updated file?
Suprise! You don't have to answer (if you know the answer at all), because I found out for myself. I ran a little test, where I synced one directory (the source) to the other (the target), hard-linked the file inside the target directory to a third directory, modified the original file in the source directory, re-synced, and finally compared the updated file in the target directory with the linked file in the third directory. The outcome: they were different. So rsync unlinks the old file rather than overwriting it in-place.
This happens to be what I hoped for, since once a day I'll make a hard-linked "meta-snapshot" of the current snapshot, and I don't want those "meta-shapshots" to be overwritten by new rsync updates.
"There are only two hard problems in computer science: cache coherence, naming things, and off-by-one errors." (Phil Karlton and Leon Bambrick) coding and xkcd combined
Feel free to call me Julian. J+ is just an abbreviation.