rsync Command Examples in Linux¶
Introduction¶
These examples show practical ways to use rsync on a Linux terminal. Each example is written so you can adapt it for administration or troubleshooting.
Example 1: Basic Usage¶
rsync -av source/ backup/
This is the simplest form of the command and is a good starting point before adding options.
Example 2: Common Admin Task¶
rsync -av /srv/app/ /backup/app/
This example reflects a common task on RHEL, Rocky Linux, AlmaLinux, or similar systems.
Example 3: Useful Option¶
rsync -av --delete source/ backup/
This option helps narrow the result, change behavior, or handle a more realistic target.
Example 4: Real-World Scenario¶
rsync -av -e ssh /srv/app/ admin@server:/backup/app/
Use this pattern when the task moves beyond a single basic command.
Example 5: Verification¶
rsync -avn source/ backup/
Example output:
sending incremental file list
app.conf
sent 1,024 bytes received 64 bytes 2,176.00 bytes/sec
Common Mistakes¶
- Misunderstanding the source trailing slash, which changes what gets copied.
- Using
--deletewithout a dry run. - Running as root when preserving ownership is not actually required.
Quick Reference¶
rsync -av source/ backup/
rsync -av /srv/app/ /backup/app/
rsync -av --delete source/ backup/
rsync -av -e ssh /srv/app/ admin@server:/backup/app/
rsync -avn source/ backup/
Related Guides¶
Summary¶
Good rsync usage means choosing the right option, keeping the target clear, and verifying the result with output you can explain.