An rsync command encodes more than two paths. Trailing slashes determine which
directory level is copied, archive mode selects preserved metadata, and
--delete makes the destination mirror the source by removing extra entries.
Use --dry-run with itemized output until that complete plan matches your
intent.
Confirm both endpoints
Resolve local paths before adding options:
readlink -f -- ./source
readlink -f -- ./destination
findmnt --target ./destinationFor a remote transfer, record the remote host, account, path, and rsync version on both ends. Shell expansion happens before rsync sees local arguments; quote paths and patterns.
The source slash changes the directory level:
rsync -a source/ destination/ # copy the contents of source
rsync -a source destination/ # create destination/sourceThat distinction is part of rsync’s source-argument rules 1.
Ask for an itemized dry run
rsync --archive --dry-run --itemize-changes \
--human-readable \
./source/ ./destination/--archive is shorthand for recursive transfer plus a defined group of metadata
options. It does not include every preservation feature; ACLs, extended
attributes, hard links, and some ownership behavior need separate review.
Itemized output begins with an update code. Common shapes include:
| Shape | Meaning |
|---|---|
>f+++++++++ name |
a regular file would be sent and created |
>f..t...... name |
file data or modification time would change |
.d..t...... path/ |
directory metadata would change |
*deleting name |
the destination entry would be removed |
The manual defines each position. Avoid treating any nonblank line as a content transfer; some lines describe metadata only 1.
Preview deletion in a disposable lab
lab=$(mktemp -d)
mkdir "$lab/source" "$lab/destination"
printf '%s\n' 'new payload' > "$lab/source/new.txt"
printf '%s\n' 'old payload' > "$lab/destination/old.txt"
rsync -ain --delete \
"$lab/source/" "$lab/destination/"
printf '%s\n' 'destination after dry run:'
find "$lab/destination" -maxdepth 1 -type f -printThe dry run should itemize new.txt and show *deleting old.txt. The final
find still lists old.txt, proving that the preview did not apply the plan.
Upstream says itemized output from a dry run should match the following real run
unless the files change or a system call fails 1.
Caution: Keep
--dry-runattached while adding--delete,--delete-excluded, filters, or a new destination. Remove it only after reviewing the complete output. A misplaced slash or empty source directory can produce a valid but destructive mirror.
Know when checksums help
Rsync normally uses size and modification time for its quick check. --checksum
reads file contents on both sides to decide whether a transfer is needed. It can
increase disk and CPU load substantially, especially across large trees.
Use a checksum when timestamps cannot be trusted and the extra I/O is acceptable:
rsync -ain --checksum ./source/ ./destination/Transfer verification is a separate concern. A completed rsync run does not authenticate the source or create an independent backup history.
Turn the preview into a change record
Save the reviewed command and output:
rsync -ain --delete ./source/ ./destination/ |
tee rsync-plan.txtRe-run the dry run immediately before the real command. If another process changes either tree, the old plan no longer describes the transfer.