rsync Commands
Fast incremental file transfer.All rsync pages
- rsync --delete: mirror a directory and remove extra filesrsync -av --delete src/ dest/ mirrors a directory and removes files that are gone from the source. Preview with -n, keep backups, limit deletions, slash rules.
- rsync --exclude: skip files and directories when syncingrsync --exclude='node_modules' --exclude='*.log' skips files while syncing. How patterns match names or paths, what a leading / anchors, and --exclude-from.
- rsync -e 'ssh -p 2222': rsync over SSH on a custom port or keyrsync -e 'ssh -p 2222' syncs over SSH on a custom port; add -i for a key or -J for a jump host. Why host:port:/path is wrong, ~/.ssh/config, and errors.
- rsync -n (--dry-run): preview what rsync would copy or deletersync -avn previews a sync without changing anything; add -i to see why each file is listed and --delete to preview removals. How to read the itemize codes.