Code & computing / QUICK REFERENCE
rsync: previews, directory paths and exclusions
Use rsync carefully: preview exact file changes, understand trailing slashes, and filter local copies before committing to a transfer.
Preview before transferring
- Version first
rsync --versionIdentify the installed rsync release before assuming the example flags are available. [1]
- Read local help
rsync --helpDisplays flags supported by that exact binary. [1]
- Show potential transfers
rsync -ani source/ backup/Dry-run in archive mode; itemized output describes intended changes. [1]
- Verbose dry run
rsync -avn source/ backup/Prints file names and metadata without copying or deleting. [1]
- Dry-run with statistics
rsync -an --stats source/ backup/Offers a summary of the proposed transfer for a local source. [1]
- See itemized changes
rsync -an --itemize-changes source/ backup/The change-code prefix distinguishes files and directory metadata. [1]
- Inspect pending deletions
rsync -ani --delete source/ backup/Lists receiver-only items that would be removed without actually removing them. [1]
- Preview selected file types
rsync -ani --exclude='*.tmp' source/ backup/Simulates synchronization while omitting temporary files. [1]
- Preview ignoring timestamps
rsync -anc source/ backup/Computes checksums in dry-run to identify same-size but different-content files. [1]
- List a local source tree
rsync --list-only source/Lists direct entries in the specified source directory without transferring. Add -r to traverse and list nested files as well. [1]
- Preview small inputs only
rsync -ani --max-size=1m source/ backup/Lists planned transfers limited by the size filter. [1]
- Check missing destination
rsync -ani source/ backup/With a nonexisting backup directory rsync can describe files it would create; check parent destination first. [1]
Understand source/destination paths
- Copy directory contents
rsync -a source/ backup/The trailing slash on source copies its contents directly into backup. [1]
- Copy the enclosing directory
rsync -a source backup/A non-slashed source normally creates backup/source and its contents. [1]
- Preview contents behavior
rsync -ani source/ backup/Compare relative file paths with the non-slashed form before copying. [1]
- Preview nested-folder behavior
rsync -ani source backup/Reveals whether the source directory name will be introduced. [1]
- Copy one file
rsync -a source/readme.txt backup/Copies the single named file into the existing backup folder. [1]
- Copy and rename one file
rsync -a source/readme.txt backup/renamed.txtUses a new basename when the destination path is not already a directory. [1]
- Copy a nested file
rsync -a source/sub/notes.txt backup/Copies just that file to backup rather than recreating the whole parent tree. [1]
- Retain relative subdirectories
rsync -aR source/sub/notes.txt backup/Copies source/sub/notes.txt relative to the current working directory. [1]
- Preserve mtimes only
rsync -rt source/ backup/Recursively copies while preserving modification times, not every archive-mode attribute. [1]
- Preserve archive metadata
rsync -a source/ backup/Archive mode includes recursion and selected owner/group/perms/link metadata as permitted. [1]
- Copy locally with progress
rsync -av --progress source/ backup/Per-file progress can help large interactive transfers but is not a performance guarantee. [1]
- Review destination identity
pwd; ls -ld source backupConfirm which paths the local shell resolves before using any write-capable command. [1]
Select or omit content
- Omit temporary suffix
rsync -ani --exclude='*.tmp' source/ backup/Any matching temporary file is omitted from the preview. [1]
- Omit a top-level cache
rsync -ani --exclude='/cache/' source/ backup/The leading slash anchors the rule to the transfer root. [1]
- Omit cache directories anywhere
rsync -ani --exclude='cache/' source/ backup/Directory-only rule protects matching cache directories and their contents. [1]
- Exclude logs
rsync -ani --exclude='*.log' source/ backup/Preview files except those with .log suffix. [1]
- Use external exclude patterns
rsync -ani --exclude-from=patterns.txt source/ backup/Read one pattern per line from an existing patterns.txt file. [1]
- Keep .txt at any depth
rsync -ani --include='*/' --include='*.txt' --exclude='*' source/ backup/Include directories for traversal before filtering non-text entries. [1]
- Prune empty copied directories
rsync -ani -m --include='*/' --include='*.txt' --exclude='*' source/ backup/Excluded-only directories are omitted when pruning. [1]
- Filter by maximum size
rsync -ani --max-size=5m source/ backup/Skip file transfers exceeding five-megabyte size threshold. [1]
- Filter by minimum size
rsync -ani --min-size=1k source/ backup/Skip files smaller than one kilobyte, not directories. [1]
- Exclude a named backup file
rsync -ani --exclude='/backup.zip' source/ backup/Excludes a file at the transfer root, not every matching nested filename. [1]
- Inspect filter evaluation
rsync -ani --debug=FILTER --exclude='*.tmp' source/ backup/Local debug output can explain which rule excluded a test file. [1]
- Review matching order
Include patterns before final --exclude='*'An early broad exclude can prevent directory traversal needed for later includes. [1]
Prevent unintended changes
- Safest first action
rsync -ani source/ backup/Always inspect intended target paths before performing a live copy. [1][3]
- Actual local archive copy
rsync -ai source/ backup/Writes files and metadata; restrict to directories that you own and intended to update. [1][3]
- Never assume deletions
- --delete is a write-capable synchronization option
Without dry-run it can remove receiver-only data under the destination transfer tree. [1][3]
- Deletion preview only
rsync -ani --delete source/ backup/Dry-run previews deletions; do not remove -n until source, target and exclusions are understood. [1][3]
- Bound deletion count
- --max-delete=NUMBER
Caps how many receiver-side deletions are permitted on a delete-enabled run. [1][3]
- Excluded data protection
- Ordinary --exclude patterns also protect matching destination files from --delete
Do not assume excluded files are deleted unless more dangerous flags change deletion rules. [1][3]
- Deleting excluded files
- --delete-excluded changes which excluded receiver files are at risk
Treat it as an advanced destructive operation; review separate before use. [1][3]
- Skip newer receiver
rsync -ani -u source/ backup/Preview whether files with newer destination mtimes will be skipped. [1][3]
- Update existing only
rsync -ani --existing source/ backup/Skips source files absent from the receiver's current tree. [1][3]
- Copy absent receiver files only
rsync -ani --ignore-existing source/ backup/Preserves existing receiver files without replacing their contents. [1][3]
- Checksum trade-off
rsync -anic source/ backup/Uses file checksums when checking for differences; additional I/O can be costly. [1][3]
- Avoid dangerous path assumptions
- Destination backup/ is different from backup/source/
Trailing slash behavior can change directory depth and deletion scope. [1][3]
- Preview regular files without archive symlinks
rsync -rni --no-links source/ backup/This simple recursive preview excludes symlink transfers. [1][3]
- Limit to filesystem
rsync -anx source/ backup/Prevents recursion into a separate mounted filesystem under the source. [1][3]
Reserved placement, separate from reference controls. No ad network is active.
No matching entry. Try a shorter word or clear the search to see the complete sheet.
Sources
cheatsheetatlas.com/sheets/rsync/ · Updated 2026-10-26 · rsync 3.5 docs; 3.4.1 local-only test fixture