Skip to main content

Rsync File Synchronization

Navigation bar

You can use the following command combinations to have rsync check first, then synchronize, while displaying a progress bar.


Direct Examples:​

For example, updating resources for this website.

# # 1. First perform a dry run (check) --- check what will be synced
rsync -avn --checksum --progress --delete /www/fanconn_wiki/wiki/ c:/www/wiki/

# 2. After confirming it's correct, perform the actual sync
rsync -av --checksum --progress --delete /www/fanconn_wiki/wiki/ c:/www/wiki/

# Show more detailed progress information
rsync -av --progress --stats --human-readable source_directory/ destination_directory/

# Or use a more intuitive progress bar (requires installing pv)
rsync -av source_directory/ destination_directory/ | pv -lep -s $(du -sb source_directory/ | cut -f1)

# 1. First perform a dry run (check)
rsync -avun --progress source_directory/ destination_directory/

# 2. After confirming it's correct, perform the actual sync
rsync -av --progress source_directory/ destination_directory/

Method Two: Check First Using the --dry-run Parameter​

# First check (dry run)
rsync -avun --progress source_directory/ destination_directory/

# Or use --dry-run
rsync -av --dry-run --progress source_directory/ destination_directory/

# After confirming it's correct, remove -n or --dry-run to perform the actual sync
rsync -av --progress source_directory/ destination_directory/

Key Parameter Descriptions​

  • -a: Archive mode, preserves file attributes.

  • -v: Verbose output.

  • -u: Skip files that are newer in the destination (sync only updated files).

  • -n or --dry-run: Perform a trial run with no actual changes made.

  • --checksum: Slowest, calculates the MD5 checksum for each file.

  • --progress: Show transfer progress.

  • --delete: Delete files in the destination directory that are not present in the source directory.

  • --delete-excluded: Also delete excluded files (if exclusion rules are used).

  • Note: The trailing slash / on the source directory is important. It means "sync the contents of the directory" rather than the directory itself.

This way, you can first see which files will be synchronized. After confirming it's correct, you can then perform the actual file transfer, while also being able to see the progress.


Image


AI Translation Notice

This page was translated into English by AI and is provided for reference only. The original document is written in Chinese. If there is any discrepancy, the Chinese version prevails.

本页英文内容由 AI 自动翻译生成,仅供参考;原文为中文,如有差异请以中文原文为准。

查看中文原文 / View the Chinese original →