Name

rsync — stdin  stdout  - file  -- opt  --help  --version

Synopsis

rsync [options] source destination

The rsync command is perfect for copying large sets of files for backups. It is also very fast because it copies only the parts of files that have changed, rather than entire files. You might remember rsync from the beginning of the book, where it solved the problem of copying only changed files to a remote server.

rsync is not as simple as Apple’s Time Machine, but it’s very flexible, supports other platforms besides OS X, and can be controlled precisely from the command line. rsync can make an exact copy of all files, including file permissions and other attributes (called mirroring), or it can just copy the data. It can run over a network or on a single machine. It’s also very fast compared to an ordinary copy command.

rsync has many uses and over 50 options; we’ll present just a few common cases relating to backups.[18]

To mirror (copy exactly) the directory D1 and its contents into another directory D2 on a single machine:

rsync -a -E D1 D2

In order to mirror directory D1 over the network to another host, server.example.com, where you have an account with username ...

Get Macintosh Terminal Pocket Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.