Nodea — logo

rsync

rsync (remote sync) is a popular Linux command-line tool for synchronising and copying files between directories on the same machine or between different servers over a network. Its advantage over simple copying is a clever algorithm that transfers only the data that has actually changed — which makes repeat synchronisations very fast and bandwidth-efficient.

How rsync works

The heart of rsync is its delta-transfer algorithm. On the first sync it copies everything, but on later runs it compares the source and destination files, breaks them into blocks and transfers only the blocks that changed. In addition, rsync:

  • preserves permissions, ownership, timestamps and symbolic links,
  • can compress data on the fly (the -z option) to reduce network traffic,
  • can delete files on the destination that no longer exist in the source (the --delete option), producing a faithful mirror,
  • offers a test mode (--dry-run) that shows what would be done without making changes.

For work between servers, rsync most often uses an SSH tunnel, which encrypts the transferred data.

rsync in practice

rsync is one of an administrator's staple tools. It is used to create backups (including incremental ones), migrate sites and data to a new server, maintain mirrors, and as part of a deployment process — new application versions are frequently synced to the production server with rsync. Because the tool runs from the command line, it is easy to automate in scripts and scheduled jobs, for example alongside cron, making it a cornerstone of many routine tasks on Linux servers.

Powiązane pojęcia

Najczęstsze pytania

Why is rsync faster than plain copying?

rsync uses a delta algorithm — on each subsequent sync it compares files and transfers only the parts that actually changed, instead of copying everything again. For large datasets where little changes, this saves enormous amounts of time and bandwidth.

Does rsync encrypt the data it transfers?

rsync itself does not encrypt, but it is most often run over an SSH tunnel, which encrypts the transmission. In that setup the data travels between servers through a secure channel, just like a normal SSH connection.