Rsync
rsync is a useful utility for synchronizing files. It can synch between hosts with SSH, locally between 2 directories, and more. A hosted version exists at rsync.net, offering a reliable, flexible solution for synchronizing files to a trusted remote.
This page focuses on the rsync CLI utility for Linux.
Installation
Installing rsync on Linux is easy, the package exists in most repositories:
## Debian/Ubuntu
sudo apt install -y rsync
## RedHat/Fedora/OpenSuSE
sudo dnf install -y rsync
## Alpine
sudo apk add rsync
Usage
Check rsync's version with rsync --version. The commands in this documentation do not cover the full functionality of rsync. Rather, they're a reflection of how I've used the tool.
Rsync Args
Note
This list is not exhaustive. It's a cheat sheet I've made for myself. If I haven't used an arg, it will not be listed below.
See a full list of rsync args, or check out an rsync cheat-sheet.
| arg | description |
|---|---|
| -r | Recursive copy (unnecessary with -a) |
| -a | Archive mode, includes recursive transfer |
| -z | Compress the data |
| -v | Verbose/detailed info during transfer |
| -h | Human readable output |
Replace cp command with rsync for faster transfers
Edit your ~/.bash_aliases file:
| ~/.bash_aliases | |
|---|---|
Examples
Sync local path to remote
| rsync local path to remote | |
|---|---|