O'Reilly logo

Linux Pocket Guide, 2nd Edition by Daniel J. Barrett

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

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

Synopsis

rsync [options] source destination

The rsync command copies a set of files. It can make an exact copy, 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. rsync has many uses and over 50 options; we’ll present just a few common cases relating to backups.

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

$ rsync -a D1 D2

In order to mirror directory D1 over the network to another host, server.example.com, where you have an account with username smith, secure the connection with SSH to prevent eavesdropping:

$ rsync -a -e ssh D1 smith@server.example.com:D2

Useful options

-o

Copy the ownership of the files. (You might need superuser privileges on the remote host.)

-g

Copy the group ownership of the files. (You might need superuser privileges on the remote host.)

-p

Copy the file permissions.

-t

Copy the file timestamps.

-r

Copy directories recursively, i.e., including their contents.

-l

Permit symbolic links to be copied (not the files they point to).

-D

Permit devices to be copied. (Superuser only.)

-a

Mirroring: copy all attributes of the original files. This implies all of the options, -ogptrlD.

-v

Verbose mode: print information about what’s happening during the copy. Add --progress to display a numeric progress meter while files are copied.

-e ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required