What to enter
Write one rule per line, in the order you'll pass them to rsync. --include=PATTERN is + PATTERN, and --exclude=PATTERN is - PATTERN.
For paths, list files relative to the folder you're copying, and end each directory with /. Include the folders that lead to the files you care about, such as photos/ and photos/2026/, because a folder's own result decides whether rsync looks inside it.
Leave Unmatched paths on Include to match rsync. A path no rule matches is copied.
How to read the result
Each path is included, excluded, or unvisited. Unvisited means rsync never reaches the path, because a folder above it was excluded.
Copy only JPEG files from a photo folder
Example
Paths: photos/, photos/2026/, photos/2026/a.jpg, photos/2026/b.raw, notes.txt, cover.jpg.
With + *.jpg then - *, the result is Included 1, excluded 2, unvisited 3. Only cover.jpg is copied, because - * excludes photos/ and rsync never looks inside.
Add + */ as the first rule and it becomes Included 4, excluded 2, unvisited 0. Now photos/2026/a.jpg is copied too.
How does rsync decide which files to copy?
rsync checks each file and folder against your rules from top to bottom, and the first rule that matches decides. A path that matches no rule is copied. The rsync manual covers the full rule language.
So order matters. Put exceptions before the broad rule they're exceptions to:
+ keep.logthen- *.logcopieskeep.logand skips the other logs.- *.logthen+ keep.logskips every log, because the first rule already matched.
Why are files in my included folder not copied?
Because a folder above them was excluded. When rsync excludes a folder, it doesn't look inside, so no later rule can bring back a file in it. This is the most common rsync filter mistake.
Include every folder on the way down. The rsync manual's own example, + foo/, + foo/bar.c, - *, copies only foo/bar.c, and notes that foo/ must be included or - * would exclude it.
How do I copy only one file type?
Include all folders first, then the file type, then exclude everything else:
rsync -av --include='*/' --include='*.jpg' --exclude='*' src/ dest/*/ matches every folder, so rsync walks the whole tree. That can leave empty folders at the destination. Add -m (--prune-empty-dirs) to skip them.
What do the pattern symbols mean?
*.confwith no slash matches a file name at any depth, such asapp.conforetc/app.conf.- A leading
/, as in/etc/*.conf, anchors the pattern to the top of the transfer, not your system's root. *matches within one path segment, so/etc/*.confdoesn't matchetc/app/site.conf.**crosses folders, so/logs/**matches everything at any depth underlogs/.?matches one character, sopart?.txtmatchespart1.txtbut notpart12.txt.- A trailing
/, as incache/, matches folders only.
A standalone ! clears every rule above it.
How do I check before copying?
Run the real command with --dry-run and -v. rsync lists what it would copy without changing anything. This tester doesn't follow symlinks, check permissions, or read .rsync-filter merge files, so the dry run is the final check.
For backups with snapshots and retention instead of plain copies, see the restic retention simulator.