Skip to content

Q&A · Answered

How to use rsync for backups

asked 9 months, 1 week ago 1246 views 1 answer
43

I need to synchronize files between servers. How do I use rsync effectively?

1 Answer

One accepted
11

Accepted answer

Not confirmed since it was written, 9 months, 1 week ago
# 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/

Your answer

Say what you tried, not only what worked — the next person needs the reasoning. Code goes in a fenced block.

Shown beside your answer and never checked, so it cannot be a name someone already has here.

No account needed to answer. Sign in instead and it carries your name and earns reputation.