Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

So, quick trick with rsync that means you don't have to copy everything and then hardlink:

    --link-dest=DIR          hardlink to files in DIR when unchanged
Basically, you list your previous backup dir as the link-dest directory, and if the file hasn't changed, it will be hardlinked from the previous directory into the current directory. Pretty nice for creating time-machine style backups with one command and no SSH.

Also works a treat with incremental logical backups of databases.



--link-dest is also used in hrsync, another rsync wrapper: https://github.com/dparoli/hrsync/blob/master/hrsync#L52


This is good to know, I used an extra "cp -rl" step in my previous scripts.


Yes - they accomplish the same thing.

--link-dest is just an elegant, built-in way to create "hardlink snapshots" the same way that 'cp -al' always did.

But note:

A changed file - even the smallest of changes - breaks the link and causes you to consume (size of file) more space cascading through your snapshots. Depending on your file sizes and change frequency this can get rather expensive.

We now recommend abandoning hardlink snapshots altogether and doing a "dumb mirror" rsync to your rsync.net account - with no retention or versioning - and letting the ZFS snapshots create your retention.

As opposed to hardlink snapshots, ZFS snapshots diff on a block level, not a file level - so you can change some blocks of a file and not use (that entire file) more space. It can be much more efficient, depending on file sizes.

The other big benefit is that ZFS snapshots are immutable/read-only so if your backup source is compromised, Mallory can't wipe out all of the offsite backups too.


It also reduces the amount of data transferred, making the backup faster.

> We now recommend

Who's we?


The poster to whom you replied is affiliated with rsync.net, a popular backup service.


One thing of note - the file is not transferred, so backups happen faster and consume less bandwidth (important if your target is not network-local to you).




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: