Introduction to rsync
Last updated on 2026-08-27 | Edit this page
Estimated time: 35 minutes
Overview
Questions
- What is rsync and why is it preferred for large file transfers?
- How do I upload and download files with rsync?
- What do the common rsync flags mean?
Objectives
After completing this episode, participants will be able to:
- Explain rsync’s advantages over other transfer methods
- Use rsync to upload files to Sagehen HPC
- Use rsync to download files from Sagehen
- Choose appropriate flags for different transfer scenarios
Why rsync?
rsync (remote synchronization) is a command-line tool designed for efficient, reliable file transfer. Key advantages:
- Incremental: Only transfers changed data on subsequent runs
-
Resumable: Can resume interrupted transfers with
-Pflag -
Efficient: Compresses data during transfer with
-zflag - Scriptable: Ideal for automated and batch operations
rsync comes pre-installed on macOS and Linux.
Windows Users: Git Bash Does NOT Include rsync
If you’ve been following along in Git Bash, rsync will
fail with command not found – Git Bash simply doesn’t ship
it, and rsync must be installed on both ends of a transfer.
Your options:
-
Use WSL (Windows Subsystem for Linux): install it
once with
wsl --installin an Administrator PowerShell; every command in this episode then works unchanged inside WSL. -
Skip rsync locally and use
scpor FileZilla (earlier episodes) for Windows-to-Sagehen transfers. - rsync still works on Sagehen itself (e.g. copying
between
/rhomeand/bigdatain an SSH session), so the server-side examples below work for everyone.
Basic Syntax
Upload to Sagehen:
Download from Sagehen:
Essential Flags
| Flag | Meaning | When to Use |
|---|---|---|
-a |
Archive mode (preserves permissions, timestamps) | Always |
-v |
Verbose output | Debugging |
-h |
Human-readable sizes (MB, GB) | Always |
-P |
Show progress + keep partial files for resume | Large files |
-r |
Recursive (directory contents) | Directories |
-z |
Compress during transfer | Slow networks |
Trailing Slashes Matter
BASH
# WITH trailing slash: copies CONTENTS of myproject into /dest/
rsync -avhP ~/myproject/ user@host:/dest/
# WITHOUT trailing slash: copies the DIRECTORY itself, creating /dest/myproject/
rsync -avhP ~/myproject user@host:/dest/
This is the most common rsync mistake. Use trailing slashes when you want to transfer directory contents.
Uploading a Single File
Output:
mydata.csv
50,000,000 100% 15.23MB/s 0:00:03 (xfr#1, to-chk=0/1)
sent 50,001,234 bytes received 35 bytes 13,333,664 bytes/sec
total size is 50,000,000 speedup is 1.00
Uploading a Directory
BASH
rsync -avhPr ~/myproject/ <myusername>@sagehen.hpc.pomona.edu:/rhome/<myusername>/projects/myproject/
All files and subdirectories are transferred recursively.
Downloading Files
Resuming Interrupted Transfers
The -P flag is essential. If a transfer is interrupted,
simply run the same command again:
BASH
# Original command (interrupted by network drop)
rsync -avhP ~/large_file.tar.gz <myusername>@sagehen.hpc.pomona.edu:/rhome/<myusername>/
# Resume by running the exact same command
rsync -avhP ~/large_file.tar.gz <myusername>@sagehen.hpc.pomona.edu:/rhome/<myusername>/
rsync detects the existing partial file and resumes from where it stopped.
Incremental Synchronization
On the second run, rsync only transfers new or changed files:
BASH
# First run: transfers all files
rsync -avhPr ~/myproject/ <myusername>@sagehen.hpc.pomona.edu:/rhome/<myusername>/myproject/
# Add a new file locally, then run again
rsync -avhPr ~/myproject/ <myusername>@sagehen.hpc.pomona.edu:/rhome/<myusername>/myproject/
# Only the new file transfers; unchanged files are skipped
Challenge: First rsync Transfer
-
Create a 10 MB test file:
-
Upload to Sagehen:
-
Verify on Sagehen:
What was your transfer speed? Does the file size match?
Expected output:
test_data.bin
10,485,760 100% 8.34MB/s 0:00:01 (xfr#1, to-chk=0/1)
On Sagehen, ls -lh should show 10M. The file transferred
completely.
- rsync is the fastest and most reliable method for large file transfers
- Always use
-Pfor large files to enable resume capability - The trailing slash on source paths is critical:
source/vssource - rsync automatically skips unchanged files on subsequent runs
- Use
-avhPas your standard flag combination