rsync
rsync copied to clipboard
Handle hardlink failures gracefully
This is a follow up to the following bugreport https://bugzilla.samba.org/show_bug.cgi?id=13656, which is missing some key information.
rsync currently seems to handle errors when trying to create hardlinks to --link-dest directory the same as any other errors, that is at the end I get a return code 23 and an error message. But in this particular example rsync did fallback on a normal copy and the destination directory is actually correct. It would be nice to have a possibility to ignore such hardlink failures while still getting an error for actual failure to copy to the destination.
The attached test script works without any errors for me on debian buster with linux kernel 4.19, or without the --link-dest option. It gives an error on linux kernel 5.10 together with the --link-dest option even though the destination directory is correct after the rsync call. I tested with rsync 3.2.3 from debian buster-backports.
Testscript: rsynctest.txt
In my application it is important that files are actually hard linked, not copied. This is why I would prefer that to be an error. Maybe this behaviour could be set up by other options?
Yeah the original report has some possibilities to remedy the situation. To repeat them here:
- still generate an error but use a different return code, as the file was still copied to target directory
- have an option to ignore hardlink errors when there is a successful fallback on normal copy
- ignore hardlink errors by default (this is the only solution which would not work in your use-case)