2

So I have been searching for this up and down, but must be doing something fundamentally wrong. What I want to do:

I have configured my NAS to make snapshots of my home folder, file system is btrfs. That works as it should and is utilizing hard links.

I want to copy off the whole snapshots directory for backup on an ext4 usb disk, using rsync -aH to preserve the hard links. But hard links are not preserved after rsync completes - I am down to a minimum example where I rsync a file of 2 different snapshots (verified to have identical Inodes) on the btrfs volume - just to another directory - which also creates 2 distinct files. Am I missing an rsync option here to make this work? Or is rsync simply incapable to do this? Wrong tool for the job?

3

I don't know rsync very well but if by "snapshots" you mean Btrfs snapshots (taken with btrfs subvolume snapshot …) then identical files in two snapshots are not hardlinked.

They possibly share space on the (physical) device because of the copy-on-write behavior of Btrfs; their inode numbers are the same, but they logically exist on different devices. In this context each Btrfs subvolume should be treated as a separate filesystem.

If you can, check files belonging to different snapshots with stat. You will see they report different device identifiers. Identical inode numbers on different devices mean nothing.

For this reason rsync has no simple clue the files "should" be hardlinked. They are not hardlinked in your "whole snapshots directory" in the first place.

I believe btrfs send and btrfs receive are tools to replicate snapshot hierarchy on another computer (with Btrfs filesystem). I have never used them though, so I cannot guide you. Study man btrfs-send and man btrfs-receive.

  • Thanks a lot Kamil, I was blinded by the inodes having identical values. I'll give the tools you mentioned a shot. – quaylar Sep 8 '18 at 21:33

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.