0

I would like to duplicate a folder structure containing many directories and files using hard links for all the files instead of making new copies of the files. I thought I could do this with rsync, but the -H option that I thought did this only preserves existing hard links.

The folder trees I want to do this with are in the same parent directory on the same volume.

Then I thought --link-dest might do it:

rsync -avh --stats --link-dest=Fold1/ Fold1 Fold2/

But that just copies the files in Fold1 to Fold2

Eduardo Baitello
  • 269
  • 2
  • 14
lbutlr
  • 113
  • 6
  • `cp -al` https://unix.stackexchange.com/a/202431 – Alexey Ten Jul 18 '19 at 12:55
  • That works, thank you, SUPPOSEDLY what I tried in rsync should work https://superuser.com/questions/1360525/can-i-hard-link-files-with-rsync-instead-of-copying-them – lbutlr Jul 18 '19 at 13:09
  • The problem you're having with `--link-dest` is because you're specifying a relative directory, and then it is relative to the destination directory. You should have specified `--link-dest=../Fold1`. I'm also wondering if you should have a trailing slash on your source `Fold1`; if not, the link-dest target should probably be simply `..`. – wurtel Jul 19 '19 at 09:58
  • @wurtel I think I tried all those variations, but cp -al works great ¯\_(ツ)_/¯ – lbutlr Jul 19 '19 at 13:47

0 Answers0