rsync -av --delete --exclude "cache/" /home/user/docs/ /mnt/backup/docs/

Category: Backup & Restore

rsync -av --delete --exclude "cache/" /home/user/docs/ /mnt/backup/docs/

Mirror while excluding a subdirectory

Combines mirroring with --delete and the --exclude pattern cache/, so the cache directory is neither copied nor deleted. Excluded files in the destination are left alone, which protects them from --delete. Verify the effect with a dry run first.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.