Control what gets copied with rsync by excluding files and folders using patterns and lists. 13.01.2026 | reading time: 3 min Use `rsync` exclude patterns to stop unwanted files from being copied; small patterns save time, bandwidth and storage while keeping the sync deterministic. Practical example Scenario: mirror "/srv/site" to "/backup/site" but skip logs, temporary directories and the Git history; run the command and observe what is not transferred: ```bash rsync -av --progress --exclude='*.log' --exclude='tmp/' --exclude='.git/' /srv/site/ /backup/site/ ``` Expected short output (files listed only when transferred): ```text sending incremental file list index.html assets/style.css sent 1,234 bytes received 234 bytes 3,456.78 bytes/sec total size 12,345 speedup 9.8 ``` To manage many rules, put them in a file and pass it: ```bash cat > /tmp/excludes.txt <<EOF *.log tmp/ .git/ EOF rsync -av --exclude-from='/tmp/excludes.txt' /srv/site/ /backup/site/ ``` Beyond the basics Patterns can be anchored with a leading slash, a trailing slash matches directories only, and `**` matches across directories; use `--filter` for advanced include/exclude sequencing and remember that exclude rules are evaluated in order so specific includes may need to appear before broad excludes, and be careful when combining `--delete` with excludes so you don't remove needed files unintentionally. Tips and gotchas Trailing slashes on source paths change behavior, per-directory ".rsync-filter" files let you store rules alongside data, `--exclude-from=-` reads rules from stdin for scripting, and when building large exclude lists use `find` or `grep` to generate entries instead of hand-editing. Complementary tools Use `find` to produce dynamic exclude lists, `tar` to create archives when metadata must be preserved, and backup systems like Borg or rsnapshot when deduplication and rotation are required; these tools complement rsync rather than replace its flexible sync engine. A short next step Try a dry run with `rsync -av --dry-run` and your exclude file, verify the result on a test dataset, then iterate on patterns until the sync does exactly what is needed; consider deepening system skills and exam readiness with CompTIA Linux+ or LPIC-1 preparation at bitsandbytes.academy for focused, intensive study. Join Bits & Bytes Academy First class LINUX exam preparation. utilities backup filesystem scripting storage