Skip to main content

Filter Patterns

Pattern Rules

PatternMatchesExample
*.logAny .log file anywhere--exclude='*.log'
/cache/cache/ at source root only--exclude='/cache/'
cache/cache/ at any depth--exclude='cache/'
*.jpgAll JPEG files--include='*.jpg'
**/*.tmp.tmp files in any subdir--exclude='**/*.tmp'
dir/***Dir and everything inside--include='dir/***'

Common Commands

# Exclude single pattern
rsync -av --exclude='*.log' src/ dest/

# Multiple excludes
rsync -av --exclude='*.log' --exclude='cache/' --exclude='tmp/' src/ dest/

# Include ONLY specific files
rsync -av --include='*.conf' --include='*/' --exclude='*' src/ dest/

# Exclude file (one pattern per line)
rsync -av --exclude-from='exclude-list.txt' src/ dest/

# Filter rules file
rsync -av --filter='merge filter-rules.txt' src/ dest/

Common Exclude Templates

web-deploy-exclude.txt
.git/
node_modules/
.env
*.log
cache/
tmp/
.DS_Store
backup-exclude.txt
cache/
tmp/
*.log
*.pid
*.sock
sessions/
tip

Order matters. Rsync processes rules top to bottom. Put --include before --exclude when whitelisting specific files.