5

I'm trying to sync all *.jpg files from /var/www/data/models/days/ + some other directories from /var/www/data root.

I do:

rsync -az --delete --include='/models' --include='*.jpg' --exclude='*' $SRC::/var/www/data /var/www/data but it doesn't sync anything. What am I doing wrong?

NOTE: I don't want to change the source or target to include /models/days as I need some other directories with the same filename matching (*.jpg).

2 Answers 2

4

You've included /models in the traversal, but none of its subdirectories. If a directory is excluded, rsync doesn't traverse it, so none of its contents can be included.

Use --include='*/' to include all subdirectories, and -m to not copy directories that would end up empty. For more information, see Rsync filter: copying one pattern only

0

Your --include option needs to take account of leading subdirectory names. Try using **.jpg instead: the rsync-specific ** operator matches slashes as well as other characters.

1
  • 1
    *.jpg matches files in subdirectories as well: if there's no / in the pattern, it's matched against the basename of the file. /*.jpg would only match files at the toplevel. **.jpg is synonymous with *.jpg. May 13, 2013 at 1:27

You must log in to answer this question.

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