You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I accidentally ran:
$ rsync -va --progress --remove-source-files "$dir_with_many_files" "$dir_with_many_files"
Due to a typo when using bash history substitution, the source and
destination were both directories and they both named the same
directory.
The expectation is that rsync should detect movement from A to A and
do nothing apart from warning the user that there is nothing to do.
Instead, because of the “--remove-source-files” option, rsync DESTROYS
all the files in "$dir_with_many_files" irrevokably.
There needs to be a safeguard that prevents --remove-source-files from
having effect if:
* Files are not copied to the destination (for any reason)
* The source and destination are the same
I suffered data loss because of this. At the very least, if it’s
really intended for “rsync --remove-source-files $A $A” to effectively
behave like “rm -rf $A/*”, there AT LEAST needs to be a very loud
warning prompting the user for confirmation. But I conjecture that there
never is a legit scenario where “rsync --remove-source-files” simply
destroys files without safely ensuring they exist somewhere in the
end.
The issue can be reproduced with:
mkdir testdir-remove-source-files-1016102 && touch testdir-remove-source-files-1016102/file-a && touch testdir-remove-source-files-1016102/file-b
ls testdir-remove-source-files-1016102
rsync -va --progress --remove-source-files testdir-remove-source-files-1016102/ testdir-remove-source-files-1016102/
ls testdir-remove-source-files-1016102
The text was updated successfully, but these errors were encountered:
Hello,
I'm forwarding this bug report I've received on Debian:
https://bugs.debian.org/1016102
I'm verbatim copying the report below:
The issue can be reproduced with:
The text was updated successfully, but these errors were encountered: