delete files

Voelker, Bernhard bernhard.voelker at siemens-enterprise.com
Wed Nov 16 01:14:26 MST 2011


Brian K. White wrote:

> ... Looks like it works, but only for files not directories.
> 
> All I did was change:
> rsync $OPTS --include=/$F --exclude='*' $P ${h}::root$P
> to
> rsync $OPTS --include=/$F --exclude='*' ${P}/. ${h}::root${P}/.
> 
> And now if the file doesn't exist locally it is deleted from the remote 
> host.

The include rule for a direftory is different (see manpage). Try

rsync -avx --include="/$F/*" --include="/$F" --exclude='*' --delete "$P" "${h}:root${P}/.

This covers cases where $F is a file or a directory with some files in there.

For deleting recursive directories, the section "INCLUDE/EXCLUDE PATTERN RULES"
will give you an idea.

Have fun,
Berny


More information about the rsync mailing list