Rsync delete only excluded files

backuprsync

rsync option --delete-excluded implies --delete as well. From man page:

–delete-excluded

In addition to deleting the files on the receiving side that are not on the sending side, this tells rsync to also delete any files on the receiving side that are excluded (see –exclude).

Is there a way to specify only delete file/dir if it was excluded, otherwise don't delete. I have a situation where I backup my homedir on my laptop to my nas device using rsync. I want to continue to delete photos from my laptop but when I sync, I don't want them deleted from nas but for I exclude some dirs from back up using –exclude and want them deleted on NAS as well.

Thanks,


TM

Best Answer

The use of filters might meet your requirements:

--filter='P /some/dir'

Related question: How to exclude rsync excludes from delete?

Related Question