Glossary

rsync

rsync is the go-to tool for efficient file synchronisation between locations, whether local or remote. Its killer feature is the rsync algorithm, which transfers only the differences between source and destination—when updating an existing directory, it sends the changed bytes instead of recopying everything. This makes it dramatically faster than scp or cp for incremental backups and mirrors.

rsync -av src/ dst/                          # local mirror
rsync -av src/ user@host:/path/              # push to remote
rsync -av user@host:/path/ dst/              # pull from remote
rsync -avP                                    # progress + partial
rsync -av --delete src/ dst/                 # remove extras from dst
rsync -av --exclude='*.tmp' src/ dst/        # exclude patterns
rsync -a --link-dest=/prev src/ new/         # hard-linked snapshots

The trailing slash on a source path matters: src/ copies the contents of src, while src copies the directory itself. This is one of the most common sources of confusion.

rsync is the backbone of many backup systems (rsnapshot, BackupPC, borgmatic with rsync), deployment tools, and mirror services. When combined with SSH, it gains encryption and authentication for free. For big local or network transfers, it is almost always the right tool.

Related terms: scp, SSH

Discussed in:

Also defined in: Textbook of Linux