Rsync is a powerful file synchronization and data transfer tool used on Linux, UNIX, and BSD systems. It is widely trusted for incremental backups, remote server replication, website deployments, and secure file transfers over SSH. Because rsync uses a delta-transfer algorithm that copies only changed data blocks, it reduces bandwidth usage and speeds up backups, making it essential for Linux VPS hosting, dedicated servers, and enterprise environments.

1. Basic File Copy

rsync file.txt /backup/
  • rsync → Synchronizes files and directories.
  • file.txt → Source file to copy.
  • /backup/ → Destination directory.

2. Copy a Directory Recursively

rsync -r /var/www/ /backup/www/
  • -r → Recursively copies directories and subdirectories.
  • /var/www/ → Source directory.
  • /backup/www/ → Destination directory.

3. Archive Mode (Preserve Permissions and Ownership)

rsync -a /home/ /backup/home/
  • -a → Archive mode (preserves permissions, ownership, timestamps, symlinks).
  • /home/ → Source directory.
  • /backup/home/ → Backup location.

4. Verbose Output

rsync -av /source/ /destination/
  • -a → Archive mode.
  • -v → Displays detailed output during synchronization.
  • /source/ → Source directory.
  • /destination/ → Destination directory.

5. Compress Files During Transfer

rsync -avz /local/ user@remote:/backup/
  • -a → Archive mode.
  • -v → Verbose output.
  • -z → Compresses data during transfer to reduce bandwidth usage.
  • user@remote: → Remote SSH user and host.
  • /backup/ → Remote destination path.

6. Use SSH for Secure Remote Transfer

rsync -av -e ssh /data/ [email protected]:/backup/
  • -a → Archive mode.
  • -v → Verbose output.
  • -e ssh → Specifies SSH as the remote shell.
  • /data/ → Local source directory.

7. Delete Files Removed from Source

rsync -av --delete /source/ /backup/
  • -a → Archive mode.
  • -v → Verbose output.
  • --delete → Removes files from destination that no longer exist in source.

8. Exclude Specific Files

rsync -av --exclude="*.log" /var/www/ /backup/www/
  • -a → Archive mode.
  • -v → Verbose output.
  • --exclude="*.log" → Excludes files matching the pattern.

9. Perform a Dry Run Before Syncing

rsync -av --dry-run /source/ /backup/
  • -a → Archive mode.
  • -v → Verbose output.
  • --dry-run → Shows what would be transferred without making changes.

10. Limit Bandwidth Usage

rsync -avz --bwlimit=1000 /data/ user@remote:/backup/
  • -a → Archive mode.
  • -v → Verbose output.
  • -z → Compresses transfer.
  • --bwlimit=1000 → Limits bandwidth to 1000 KB per second.

11. Show Transfer Progress

rsync -av --progress /largefiles/ /backup/
  • -a → Archive mode.
  • -v → Verbose output.
  • --progress → Displays real-time file transfer progress.

12. Sync Only Newer Files

rsync -avu /source/ /backup/
  • -a → Archive mode.
  • -v → Verbose output.
  • -u → Skips files that are newer on the destination.

13. Copy Only Specific File Types

rsync -av --include="*.php" --exclude="*" /var/www/ /backup/www/
  • --include="*.php" → Includes only PHP files.
  • --exclude="*" → Excludes all other files.
  • -a → Archive mode.
  • -v → Verbose output.

14. Create Incremental Backups

rsync -av --link-dest=/previous_backup/ /source/ /current_backup/
  • -a → Archive mode.
  • -v → Verbose output.
  • --link-dest=/previous_backup/ → Hard links unchanged files to save space.

15. Mirror a Remote Server to Local Machine

rsync -avz user@remote:/var/www/ /local/backup/www/
  • -a → Archive mode.
  • -v → Verbose output.
  • -z → Compresses data during transfer.
  • user@remote:/var/www/ → Remote source directory.

Why Rsync Is Essential for Linux VPS and Server Backups

Rsync is one of the most important tools for Linux system administrators, DevOps engineers, and hosting providers. It is commonly used for secure remote backups, automated cron-based backup scripts, disaster recovery solutions, and website synchronization. Because rsync minimizes data transfer and preserves file attributes, it is ideal for high-performance VPS servers, NVMe storage environments, and unmetered bandwidth infrastructure.

Final thoughts

These 15 useful rsync examples show how versatile and powerful rsync is for Linux file synchronization and secure server backups. Whether you are migrating a VPS, synchronizing web servers, building automated backup solutions, or managing enterprise Linux infrastructure, mastering rsync will help you improve performance, reduce bandwidth usage, and protect critical data. Rsync remains one of the most efficient and reliable tools for Linux server administration.

¿Le ha resultado útil esta respuesta? 5546 Los usuarios encontraron esto útil (5547 Votos)