43
I need to synchronize files between servers. How do I use rsync effectively?
Loading...
Q&A · Answered
I need to synchronize files between servers. How do I use rsync effectively?
Accepted answer
# Basic sync
rsync -avz /source/ /destination/
# Sync to remote server
rsync -avz -e ssh /local/ user@remote:/path/
# Important flags
# -a: archive mode (preserves permissions)
# -v: verbose
# -z: compress during transfer
# --delete: remove files not in source
# --dry-run: test without changes
# --progress: show progress
# Backup with date
rsync -avz --backup --backup-dir=/backup/$(date +%F) /data/ /backup/current/Say what you tried, not only what worked — the next person needs the reasoning. Code goes in a fenced block.