Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

The following command copies files recursively from $MIRROR_SOURCES relative to $MIRROR_SOURCE to $MIRROR_DEST; but the delete flag does not work.

rsync -var --files-from=$MIRROR_SOURCES --delete $MIRROR_SOURCE $MIRROR_DEST
share|improve this question
    
Are there any files in $MIRROR_SOURCES that aren't in $MIRROR_SOURCE? –  Ignacio Vazquez-Abrams Aug 20 '12 at 0:51
    
@IgnacioVazquez-Abrams: no. sources contain a list of directories that are present and then rsync recursively copies the files in those listed directories. –  Ablue Aug 20 '12 at 0:57
    
Then what do you expect it to delete? –  Ignacio Vazquez-Abrams Aug 20 '12 at 0:58
    
@IgnacioVazquez-Abrams: I expect it to delete files from DEST that are not present in SOURCE. Eg. A mirror copy. –  Ablue Aug 20 '12 at 0:59
add comment

1 Answer 1

up vote 1 down vote accepted

Read --delete in man rsync carefully, emphasis mine:

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. Files that are excluded from the transfer are also excluded from being deleted unless you use the --delete-excluded option or mark the rules as only matching on the sending side (see the include/exclude modifiers in the FILTER RULES section).

Bottom line of the story is that it only does this for what you specified to be synchronized and dependent on whether you specified a wildcard or not, if you don't want that but instead want to have it happen everywhere, then you can specify the --delete-excluded flag as well.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.