I use rsync with great pleasure for backing up my servers, although I do have a question about the --delete-excluded parameter.

/usr/bin/rsync -a --delete --numeric-ids --relative --delete-excluded     --rsh=/usr/bin/ssh root@server01:/etc /.snapshot/hourly.0/server01

From man rsync:

 --delete-excluded       also delete excluded files from dest dirs

To me, a non English native, this means that rsync will delete excluded directories from the actual destination directory on the remote server, so if I have /home/backup and /home/settings in my exclude-folders, those folders would actually be removed from the remote server,.

From several other resources it seems that it will delete the files from the local backup folder in order to save space. For example you can create small back-ups on the server itself and exclude this data, so you won't waste storage space.

It is vital for me though that rsync will do it's job only one-way as people say it's meant to work, I do not want to take any risks in having software that deletes files/directories on the remote server.

1 Answer 1


Your interpretation is correct. If you have excluded files or directories from being transferred, --delete-excluded will remove them from the destination side (this does not have to be the "remote server", you can use rsync to copy from a server to the local computer) if it finds them there. For instance, if you use --exclude=*.o --delete-excluded, then if rsync finds any files ending in .o on the destination side, it will remove them whether they exist in the source directory or not.

  • 1
    So it will remove the directories/files from /.snapshot/hourly.0/server01 and not the remote server?
    – ujjain
    Jun 12, 2011 at 15:07
  • 3
    @chronoz If you are copying from the remote server to the local computer, then the destination is the local computer. If you are copying from the local computer to the remote server, then the destination is the remote server. The destination is what is important here. If the destination is the remote server, then it will remove the files from the remote server.
    – DerfK
    Jun 12, 2011 at 15:26
  • Confirmation here: comentum.com/rsync.html
    – SDsolar
    Aug 23, 2017 at 0:13
  • 7
    I've recently discovered that "--delete-excluded" is completely equivalent to "--delete --delete-excluded". In the answer example provided above, remote files that aren't present on the source side will also be deleted.
    – Wayne
    Apr 15, 2018 at 21:19
  • Beware: --delete-excluded will also remove the target directory, even if the exclude pattern is dir/ with a trailing slash. Normal rsync semantics usually use / as a shortform for referring to the contents of the dir not the dir itself. In exclude this 'inclusivity' should be reversed of course, to allow differentiation between --delete-excluded --exlcude=dir vs --delete-excluded --exclude=dir/ -- to get the full behaviour expected, one needs instead to use --delete=dir/{,.}*
    – math
    Oct 15, 2020 at 15:57

You must log in to answer this question.

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