0

How can one recursively copy all files of a specific pattern (*.tpl) using rsync?

Example:

/etc/test.tpl
/etc/dir/test.tpl
/etc/dir/**/test.tpl
Spyros
  • 135

1 Answers1

0

One command that solves this is:

rsync --dry-run --verbose --recursive --relative --prune-empty-dirs --include="**/" --include="*.tpl" --exclude="*" /source /dest/
  • --relative: Recreate all parent folders.
  • --include="**/": The ** part allows recursion for folders (/).
  • --include="*.tpl": The pattern.
  • --exclude="*": Exclude the rest.

So far, we have included the whole folder structure, albeit with empty folders.

  • --prune-empty-dirs: Remove empty folders [from the list].
Spyros
  • 135