Using NTFS hard links to combine full/differential backups

17

8

Short: Is it possible to (robo)copy a directory tree using hard links instead of physical copy?

I want to make a daily backup of my data files, every day in it's own directory. Now most files don't change every day, so my idea to speed up backup and use less disk space was to copy the backup of (day-1) to (day) using hard links, then use robocopy to replace the files which have changed since yesterday. This way I would only need to copy the full backup once to the USB drive, afterwards I could just copy the changes and still have directories containing all the files, sharing files with other backups using hard links. This way I got two full backups but it uses only file space for one+differential, and the backup files are accessible without need for special software, which is a big plus for me.

Is this possible?
Is there a program to create hard link copies of all files in a directory tree?
Am I missing some pitfall I'm not aware of?

Sam

Posted 2011-06-14T08:12:43.500

Reputation: 1 804

This can be done as found here: http://blog.mutable.net/post/2007/01/17/an-intelligent-backup-system-for-windows-part-4.aspx

– Bryan – 2011-12-14T23:35:36.720

Answers

9

There is a way to make backups like you say, but I don't believe with Robocopy alone.

There are several programs that will hard link or dedupe backups, and be space efficient.

Here are a few programs I've used or ran across:

  • Dupemerge - free - While not a "backup program" it is a bulk hard linker.
  • hardlink backup - free for personal use - uses hard links
  • Duplicati - free - (dedupes I believe like rsync does)
  • rdiff-backup - free - dedupes like rsync

I believe what may be a good fit for your questions is Dupemerge. You could have a batch file execute Robocopy to copy the contents to a directory (ex. d:\backups\YYYY-MM-DD). When that command is done, the batch file could call Dupemerge on d:\backups. That would hard link the files within and across all the subdirectories of d:\backups.

The downside of this is you would need enough space on the external to hold the newly created unhard linked backup. After Dupemerge is run, the newly created backup will be hard linked and the space will be freed.

This would make restoring easy because each dated directory would appear to have a full backup.

As a side note, if you are going to use hard links, I like Link Shell Extension. It helps let you know what isn't hard linked, what is and what it is linked to.

I’ve run across other hard link or deduping programs, but I liked these the best.

Scott McClenning

Posted 2011-06-14T08:12:43.500

Reputation: 3 519

Great summary of options. Unfortunately your recommendation doesn't cater to the original poster's request of only copying changed files on each subsequent backup. Sounds like ln.exe is a better bet. – Simon East – 2019-09-12T10:05:30.140

There's also the Link Shell Extension by the same makers of ln.exe which provide a simple way to make these kinds of backups using the mouse in Windows Explorer. It also creates timestamped directories for you during the backup process.

– Simon East – 2019-09-12T10:27:08.783

@afrazier, I know it is many years later, but: ln.exe sounds like an answer to me, especially as it provides /bat/DeLoreanCopy.bat that does just what the OP asked, and is smart about --delete for read-only files? Care to post as an answer? Its license might need some special remark though.

– Arjan – 2019-12-11T14:06:02.437

5

+1 For having a decent roundup and mentioning LSE. However, you forgot the single tool that gives the OP almost exactly what he wants: ln.exe's Delorean Copy ln.exe is written by the same person who write both Dupemerge and LSE. All that's missing is VSS support and... oh look! Here we go! ;-)

– afrazier – 2011-12-15T03:50:05.537

@afrazier good call with Delorean Copy. Looks like Delorean Copy has some good features, also that website is good for NTFS link information, I should read it more. I'm surprised about the 1023 link limit on Delorean Copy, however, probably not a problem for most. Dupemerge will link to another file at 1022 links. I guess the way the Delorian Copy works, linking to a non-source file wouldn't be desirable? I will have to read up more on it. Great suggestion. – Scott McClenning – 2011-12-15T07:32:37.613

2The 1023 link limit is an NTFS limitation -- The directory entry's link counter attribute is only 10 bits. – afrazier – 2011-12-22T17:28:06.660

1

BackupAssist will let you exactly what you require. Its use of hardlinks is named "Single Instance Store", but it's actually hard links under the hood. It can be used, among other things, to backup to USB drives the way you asked for, or to remote locations using rsync.

Zlika

Posted 2011-06-14T08:12:43.500

Reputation: 11

1

We have written our own tool for that kind of work. Its called ntfs-hardlink-backup: https://github.com/International-Nepal-Fellowship/Windows-Tools/tree/master/ntfs-hardlink-backup

For creating the hardlinks its uses the ln tool of Hermann Schinagl: http://schinagl.priv.at/nt/ln/ln.html

So you could also use ln directly. Its pretty powerful

INDIVIDUAL-IT

Posted 2011-06-14T08:12:43.500

Reputation: 271

Please quote the essential parts of the answer from the reference link(s), as the answer can become invalid if the linked page(s) change. – DavidPostill – 2015-01-28T08:25:20.523

1http://schinagl.priv.at/nt/ln/license.txt – bummi – 2015-01-28T11:35:26.063

-3

There is a flaw in your logic in the first place.

If you create hard links how can that be called a backup? once your file gets deleted/corrupted, your so-called backup goes that way too. All the requirements that you specified are usually covered by today's backup software.

P.S.: NTFS does't support hard links AFAK.

anilmwr

Posted 2011-06-14T08:12:43.500

Reputation: 13

3Sorry, my description was not clear enough: I create a full copy using robocopy on a external USB drive. For the next day, I create a hard link copy, then replace all the files which have changed since yesterday. Now I have a two full copies on my USB drive, but at the space cost of one full + one differential. – Sam – 2011-06-14T08:41:57.790

4Oh, and of course NTFS does support hard links. – Sam – 2011-06-14T08:42:15.763

1

The technique you describe is exactly what rsnapshot (seems to be down ATM) implements in Unixoid OS. It is definitely possible and works very well. Unfortunately for you rsnapshot doesn't run on Windows (that's why I write this as a comment only). But the FAQ mentions something about remote syncing Windows clients. If you have Unixoid machines around maybe this would work for you. I don't know any Windows equivalents of rsnapshot.

– Daniel Böhmer – 2011-06-14T08:59:27.090

I don't see any gain by creating hard links to unchanged files. Backup softwares take backup based on Archive bit on/off. You should just copy those files which are modified since last backup. Also, I was under the impression that ONLY Unix File Systems support hard links. Thanks to bring it to my notice! – anilmwr – 2011-06-14T09:11:28.727

@Halo Thought it should be used already at a lot of places. Pity I got no Unix-Computers around, so I'll have to wait for someone who knows about this for windows. Thanks for the heads-up! – Sam – 2011-06-14T09:15:31.863

@Sam: I didn't see your modified question before commenting. Well, If you want to create similar directory/file structure using full+differential backups, then it should be possible with a simple Perl/Python script. – anilmwr – 2011-06-14T09:25:17.290