0

I am now creating hard links to remove duplicate space usage in backup data. This is within single NTFS partitions.

I am afraid of data-loss - losing a file completely if one link reference is broken, other link references will be lost if one is deleted, or more versions change when one version change.

Is there some way to do this that will branch off the file if one changes. (If there are two link references to a file, and one changes, we get 2 independent files.)

Any risks with syncing solutions like Dropbox?

For now I am only dealing with files, not directories.

  • Are you referring to changes on the backup disk directly, for "If there are two hard links to a file, and one changes, we get 2 independent files"? (Then: no, you cannot do that, and should always have multiple backup disks.) – Arjan Oct 12 '15 at 6:16
  • Say I have 2 word documents that are the same, my duplicate cleaner could merge them so there are 2 links to the same file. Though if I edit the file, only one should normally change (They should become two different versions, because the linking is just something I do to save space). – Olav Oct 12 '15 at 6:58
  • (Would be happy if someone could propose a better terminology). – Olav Oct 12 '15 at 6:59
  • How much data is really duplicated on your computer? I'd only use hard links on the backup, not on the source. That's also how Apple's Time Machine works, and rsync's --link-dest option. – Arjan Oct 12 '15 at 7:20
  • ...and as for "other versions (links to the same file) will be lost if one is deleted": no worries, that's not how hard links work. So, please read about how hard links work and come up with a single question? (And beware of the XY problem.) Now the only obvious answer is: yes, you can lose data, if you use hard links the wrong way. – Arjan Oct 12 '15 at 8:03
0

Branching off files in case of changes is easy using hard links: Just delete the file that changed by path and put the changed one in place. Hard links point to data, but are independent paths and therefore can be deleted without affecting other hard links or the data itself. The only risky part is writing directly into the file behind a hard link, because this of course would change the data for all hard links pointing to that data, simply because there's only one data for all "the same" hard links available. So you need to know if things have changed and if so need to create a new file.

As you are asking for backup purpose, your problem shouldn't arise anyway: Each change of a file should result in a new file in the backup, without any change you can create hard links to already available data. So your process would need to check for changes first anyway, I don't see where you need to decide if and how you want to change things in the backup. Backup is about leaving everything already present as it is and only decide how to add new things.

In general, I would not recommend implementing such things on your own, it's simply too complex and too easy to get things wrong. There are already solutions available implementing what you have in mind, e.g. a tool called HardlinkBackup.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.