📅 2020-Jun-11 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ cheatsheet, rsync ⬩ 📚 Archive
Rsync is a tool that makes it easy to copy or sync contents across local and remote computers.
$ rsync -av /home/joe/from-dir /media/backup/to-dir
$ rsync -av /home/joe/from-dir chetan@some-remote:/media/backup/to-dir
$ rsync -av chetan@some-remote:/home/chetan/from-dir /media/backup/to-dir
$ rsync -av joe@some-remote-1:/home/joe/from-dir chetan@some-remote-2:/media/backup/to-dir
This recursively copies over all the files and directories in the source directory.
-v
is verbose, to print list of files being synced. -a
is a combination of options required for archival: -rlptgoD
.
Prying apart the options inherent in -a
, we get: -r
recursive, -l
copy symlinks as symlinks, -p
preserve permissions, -t
preserve modification times, -g
preserve group, -o
preserve owner and -D
preserve device files and special files.
--delete
) it may have:$ rsync -av --delete /home/joe/from-dir /media/backup/to-dir
-z
) to save transfer time, especially if a remote computer is involved:$ rsync -avz /home/joe/from-dir chetan@some-remote:/media/backup/to-dir
For example:
$ rsync -a /some/path/foobar .
$ ls
foobar/
For example:
$ rsync -a /some/path/foobar/ .
$ ls
content.txt
of.txt
foobar.txt
$ rsync joe@foobar:"path/to/some\ thing" .
$ rsync -a --no-recursive /some/path/foobar/ .
Tried with: rsync 3.1.2 and Ubuntu 18.04