Rsync
Last updated
Was this helpful?
Last updated
Was this helpful?
, standing for Remote SYNChorize, is an open source tool which provide fast incremental file transfer. As same as scp
command, rsync
can simply transfer data via ssh/rsh. More over, rsync
itself can also be a daemon if needing for lower CPU overhead and faster transfer rate.
Remote-shell transport format would be familiar to you. A single colon (:) separate a host specification and source/destination path.
To sync files from remote to local is just like cp/scp:
Or backup to remote
If you use non-default port for your remote-shell program, or want to add some different feature while transfer via ssh/rsh, just add specified remote-shell command after -e
option:
A rsync daemon is mostly used when your want to constantly maintain a synchronization. It can save some CPU usage and speedup transfer rate a bit.
To use rsync daemon for sync, a double colon (::) is required to separate the host specification and the module, or using rsync://
schema. Using double colon almost the same as single colon. The only difference is the module parameter. We will cover it later.
The default rsync daemon TCP port typically using 873.
However, rsync daemon would not encrypt data while transfering by default, you should manually encrypt by ssh
command as your needs. (Encryption may lower some speed, but is necessary when connecting to internet.)
The rsync
schema is another way to do the same thing:
ATTENTAION!! : rsync has a trick that if the source path without an trailling slash, it would create a directory with the same name inside the destination directory. Otherwise, it would only sync files inside source directory.
Here are some common options for rsync
-a
: archive mode, the same as using -rlptgoD
.
-r
: rescursive
-l
: copies symlinks as symlinks
-p
: preserves permissions
-t
: preserves modification times
-g
: preserves group
-o
: preserves owner
-D
: preserves device files
-H
: preserves hard links
-S
: handle sparse files efficiently
-X
: preserves extended attributes
-v
: increase verbosity (can add up to tree -vvv
for the most verbosity)
-z
: compress data during the transfer
--delete
: differential clean-up during sync, like a mirror backup
--numeric-ids
: do not map uid/gid values by user/group name
--progress
: show the transfer progress during
--password-file=**FILE**
: read rsync-daemon-access password from this FILE
Following rsync combined with options is the most usefule combination I've used.
As mentioned above, using rsync daemon have a bit advantage when sync constantly. To setup a rsync daemon is as simple as setting up a ssh server. For convenience, We will explian how to setup a daemon with a Network-attached Storage in the next chapter.
-A
: preserves ACLs (A more specific access rights table. See .)
-x
: don't cross file-system boundaries (A filesystem boundary is a mount point. !)