A risky rsync command deserves a preview before it writes to the destination, especially when the live command will update existing files or remove destination-only files. A dry run lets the same source, destination, and options build the transfer list without copying data or deleting files.

The preview should use –dry-run together with –itemize-changes. The dry run keeps rsync from making changes, while itemized output marks new files, changed files, attribute updates, directory touches, and deletions that would happen if the same command ran without –dry-run.

Use the exact options planned for the real sync, including –delete only when the live command should remove destination-only files. The itemized list should match the later real run as long as the source and destination do not change in between, but dry-run progress and transfer statistics are not proof because no file data is transferred.

Steps to preview rsync changes before syncing:

  1. Build the rsync command with the same source, destination, and sync options planned for the live run, then add –dry-run and –itemize-changes.
    $ rsync -a --dry-run --itemize-changes /src/ /dest/

    The trailing slash on /src/ means rsync previews copying the contents of that directory into /dest/. Remove the slash only when the destination should receive a top-level src directory.

  2. Include –delete in the dry run only when the live command will also use –delete.
    $ rsync -a --dry-run --itemize-changes --delete /src/ /dest/
    *deleting   obsolete.log
    >f+++++++++ reports/new-report.txt
    >f.s....... reports/summary.txt

    –delete removes files that exist only on the destination during the real run. Keep it in the dry run if the real mirror should delete those files, and remove it from both commands when destination-only files must stay.

  3. Read each itemized line before approving the sync. Lines beginning with >f are files rsync would send to the destination, +++++++++ marks a new file, s marks a size change, and *deleting marks a destination file that would be removed.
  4. If the preview shows too much, adjust the rsync command before running it live. Add or change excludes, fix the source path, remove –delete, or correct the destination path, then repeat the dry run.
  5. Confirm that the dry-run output lists only the intended creates, updates, attribute changes, and deletions before approving the live command.
  6. Run the real sync only after the preview matches the intended change set by removing –dry-run and keeping the reviewed options.
    $ rsync -a --itemize-changes --delete /src/ /dest/
    *deleting   obsolete.log
    >f+++++++++ reports/new-report.txt
    >f.s....... reports/summary.txt

    Keep –itemize-changes on the live command when the final log should record the changes that were actually applied.