I have a rsync command in an application that copies the contents of a folder to another machine. I have the option --remove-source-files because I'm only interested in having the files on the destination machine after the rsync has finished.

However, I was wondering how rsync behaves if it crashes or is interrupted while transferring files?

Consider I have two files to sync, a and b. Will rsync copy a, then delete it from source, and start copying b, or will it wait for both a and b to be copied to the destination machine before deleting them both? I've seen you can configure this behavior when deleting extraneous files with some flags, but found none about the removing of source files.

  • similar to stackoverflow.com/questions/7380234/… though I think Kyle may be right - sometimes it seems rsync waits for all files to complete, but sometimes it does delete the files before completion. Still a bit confused though.
    – Chris2048
    Commented Apr 28, 2012 at 11:32

3 Answers 3


Checking the rsync code reveals that source files are removed as they are sent, although it may not happen immediately. rsync multiplexes its operations, so the message that a file was successfully received (and can therefore be deleted) might be queued behind other data.

  • 2
    As per my answer below I tried it with a couple of files, and files were only deleted if the complete operation was successful. That makes me think that the "transfer OK" signal you found is only permeated when the complete operation is successful. Commented Mar 28, 2012 at 15:56
  • 5
    If you try it with more than a few files, you'll see source files disappearing before the whole transfer is done.
    – Kyle Jones
    Commented Mar 28, 2012 at 15:57
  • it looks like that when specifying directories and the recursive option, files in a are not deleted immediately Commented Nov 21, 2014 at 9:30
  • @KyleJones Are you sure? I'm using rsync -v --stats --progress --remove-source-files -avz * pi:/home/pi/moz/genius/s1 and it doesn't seem to work. If it copies 3 files and I re-run the command then when it starts it deletes those but I have to re-run the command each time for it to run delete operation and it doesn't do it on it's own one after another. Commented Sep 30, 2020 at 19:23
  • 1
    I answered the question eight years and many rsync revisions ago, and so I can't vouch for what rsync does at the moment. I also can't speak to any bugs there might be in the implementation. If you say it isn't deleting files for you, I believe you.
    – Kyle Jones
    Commented Oct 1, 2020 at 0:22

I tried it (and you could easily do it too, to be sure). They are removed after all files are transferred successfully. If the transfer is interrupted or another error occurs, the source files are not removed, even if some of them transferred OK.

EDIT: as per Kyle Jones's answer, the case might be different when many files are involved.


I just tried it, it appears units will be deleted as they are transferred if rsync <src_a> <src_b> .... <dst> but not files within a directory as the argument

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .