Intermediate LevelLinux Commands & SysAdmin
How does rsync efficiently sync files locally and over SSH using delta transfer algorithms?
❓ Interview Prompt: Explain rsync, delta transfer algorithm, archiving flags (-avz), SSH transport (-e ssh), --delete flag, and dry-run (--dry-run).
'rsync' (Remote Sync) efficiently synchronizes files locally or over SSH by using a delta transfer algorithm that transmits ONLY the modified file diffs rather than re-copying entire files!
Key Flags:
•
'-a' (Archive mode): Preserves permissions, symlinks, timestamps, and ownership recursively.
•
'-v': Verbose | '-z': Compress data during transfer.
•
'--delete': Deletes files in destination that no longer exist in source (mirroring).
•
'--dry-run': Simulates sync execution without altering files.
Code Implementation Example
bash
# Dry-run simulation of rsync directory backup
rsync -avz --dry-run /var/www/app/ deploy@backup-server:/backups/app/
# Mirror directory over SSH deleting stale destination files
rsync -avz --delete -e ssh /var/www/app/ deploy@192.168.1.50:/backups/app/💡Synchronizing directories over SSH using rsync delta compression.
🎯 Interview Key Takeaway
Use rsync -avz --dry-run to test file sync operations safely before executing live transfers.
#rsync#File Sync#Delta Transfer#Backup#Intermediate
Back to all Linux Commands & SysAdmin Questions→