CRTS
2020-Nov-06 07:25 UTC
Destination file lost with --link-dest and --backup-dir options
Hello, I am facing an issue when using --link-dest and --backup-dir together. When a source file differs from the file in the destination directory and the --backup and --backup-dir options are provided then a copy of the destination file is made in --backup-dir. However, if additionally --link-dest is provided and the source file is found in --link-dest then the file in the destination is not copied to --backup-dir but deleted instead. The following commands demonstrate the issue:> mkdir src ref tgt bkp > touch src/file ref/file > > sleep 1 > > echo "content" > tgt/file > > echo "Initial stats: stat -c '%i %n %y'" src/* ref/* tgt/* bkp/* > stat -c '%i %n %y' src/* ref/* tgt/* bkp/* > > echo > echo "Running: rsync --link-dest=../ref -a -b --backup-dir=../bkp src/ tgt" > rsync --link-dest=../ref -a -b --backup-dir=../bkp src/ tgt > > echo > echo "Final stats: stat -c '%i %n %y'" src/* ref/* tgt/* bkp/* > stat -c '%i %n %y' src/* ref/* tgt/* bkp/* > echo "File in 'tgt' is hardlinked against 'ref' but no backup of previous file in 'bkp'."I checked the manpage entries for --link-dest and --backup-dir, none of them explain the observed behaviour. While the passage at --link-dest warns that destination files may get their attributes "tweaked", it doesnot explicitly state that the --backup and --backup-dir options will be ignored.