Bug 6307 - "rsync --remove-source-files foo/ foo/" should not delete files
Summary: "rsync --remove-source-files foo/ foo/" should not delete files
Status: NEW
Alias: None
Product: rsync
Classification: Unclassified
Component: core (show other bugs)
Version: 3.0.5
Hardware: x86 Linux
: P3 enhancement (vote)
Target Milestone: ---
Assignee: Wayne Davison
QA Contact: Rsync QA Contact
Depends on:
Reported: 2009-04-30 12:10 UTC by Candid Dauth
Modified: 2017-01-12 13:16 UTC (History)
2 users (show)

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description Candid Dauth 2009-04-30 12:10:48 UTC
I wanted to move the files of a directory (whose path was only slightly different from the current directory) to the current directory. Unfortunately, I errorneously passed the current directory as first parameter instead of the other one. The rsync call was rsync --append -avAHSP --remove-source-files /path/to/current/directory/ .
The files in the current directory were deleted. I think rsync should check whether the source and the destination files are the same (like mv does, for instance) and in that case prevent the files from being deleted.
Comment 1 RC 2010-02-20 20:34:38 UTC
A big _me too_ on this one.  

"Gee, my main storage space is nearly full, I need to move it off to another disk immediately...  It's kinda important so I don't want to use mv and just hope everything goes okay...  You know, if I use rsync, I'll get file checksuming, and some stats.  Perfectly.  Let me just wrap-off a quick cmd-line before we run out of space.  Perfect!  Hmm, where'd they go?  Dammit!  200 GBytes of 'didn't have a chance to back it up yet' data GONE.  Thanks rsync!"

While I recognize my mistake in all of this, and while important and irreplaceable, the data wasn't critical, but I remain in a mild furor over pretty much the one and only possible way this could go wrong, not being checked for, despite how trivial doing so would be...  This is just a complete lack of design fore-thought on a critical-data tool.  Combine this with the terrible performance I'm seeing on filesystems with large numbers of files/folders, and my days of promoting rsync are over.  I guess it's time I really check out Unison...
Comment 2 tomboshoven@gmail.com 2015-06-28 11:44:52 UTC
Same for me. No data loss here, but a bunch of work undeleting the files and moving them back to the right directories.

Files should only be removed if they are actually copied to another location.