HELP: need better understanding of "--delete" flag

Wayne Davison wayned at
Wed Nov 23 23:30:48 GMT 2005

On Tue, Nov 22, 2005 at 08:08:56PM -0800, Jeff Martin wrote:
> Need to understand exactly what the "--delete" flag does when rsync
> runs. 

I think the rsync manpage explains this quite well:

    This tells rsync to delete extraneous files from the receiving side
    (ones that aren't on the sending side), but only for the directories
    that are being synchronized.  You must have asked rsync to send the
    whole directory (e.g. "dir" or "dir/") without using a wildcard for
    the directory's contents (e.g. "dir/*") since the wildcard is
    expanded by the shell and rsync thus gets a request to transfer
    individual files, not the files' parent directory.

> But, would rsync under any circumstances, ever delete files on the
> source machine?

If --remove-sent-files was used and if the source machine wasn't marked
as read-only, and if the --remove-sent-files option (or --delete in
general) wasn't configured to be refused by the daemon, that is the only
time that files on the sending side would be removed.

> rsync --delete -a $HOME/emptydir/ $BSERVER::$USER/$BACKUPDIR/

Since you're sending files *to* the daemon, it's entirely appropriate
for it to be logging which files were locally deleted (since the daemon
is the receiving side).  If you were pulling files from an rsync daemon,
the logs would not contain messages about what the client (receiver) was


More information about the rsync mailing list