Full List of RSYNC options for Linux Terminal(Advanced Users)

 

Below is a list and explanation of the RSYNC application within the Linux OS Environment. Use this information as a reference to help you connect your Linux machine to an rSyncIT server.


SYNOPSIS

rsync [OPTION]... SRC [SRC]... [USER@]HOST:DEST

rsync [OPTION]... [USER@]HOST:SRC DEST

rsync [OPTION]... SRC [SRC]... DEST

rsync [OPTION]... [USER@]HOST::SRC [DEST]

rsync [OPTION]... SRC [SRC]... [USER@]HOST::DEST

rsync [OPTION]... rsync://[USER@]HOST[:PORT]/SRC [DEST]

DESCRIPTION

rsync is a program that behaves in much the same way that rcp does, but has many more options and uses the rsync remote-update protocol to greatly speed up file transfers when the destination file already exists.

The rsync remote-update protocol allows rsync to transfer just the differences between two sets of files across the network link, using an efficient checksum-search algorithm described in the technical report that accompanies this package.

Some of the additional features of rsync are:

 

o
support for copying links, devices, owners, groups and permissions
o
exclude and exclude-from options similar to GNU tar
o
a CVS exclude mode for ignoring the same files that CVS would ignore
o
can use any transparent remote shell, including rsh or ssh
o
does not require root privileges
o
pipelining of file transfers to minimize latency costs
o
support for anonymous or authenticated rsync servers (ideal for mirroring)

GENERAL

There are six different ways of using rsync. They are:

 

o
for copying local files. This is invoked when neither source nor destination path contains a : separator
o
for copying from the local machine to a remote machine using a remote shell program as the transport (such as rsh or ssh). This is invoked when the destination path contains a single : separator.
o
for copying from a remote machine to the local machine using a remote shell program. This is invoked when the source contains a : separator.
o
for copying from a remote rsync server to the local machine. This is invoked when the source path contains a :: separator or a rsync:// URL.
o
for copying from the local machine to a remote rsync server. This is invoked when the destination path contains a :: separator.
o
for listing files on a remote machine. This is done the same way as rsync transfers except that you leave off the local destination.

Note that in all cases (other than listing) at least one of the source and destination paths must be local.

SETUP

See the file README for installation instructions.

Once installed you can use rsync to any machine that you can use rsh to. rsync uses rsh for its communications, unless both the source and destination are local.

You can also specify an alternative to rsh, either by using the -e command line option, or by setting the RSYNC_RSH environment variable.

One common substitute is to use ssh, which offers a high degree of security.

Note that rsync must be installed on both the source and destination machines.

USAGE

You use rsync in the same way you use rcp. You must specify a source and a destination, one of which may be remote.

Perhaps the best way to explain the syntax is some examples:

 

rsync *.c foo:src/

this would transfer all files matching the pattern *.c from the current directory to the directory src on the machine foo. If any of the files already exist on the remote system then the rsync remote-update protocol is used to update the file by sending only the differences. See the tech report for details.

 

rsync -avz foo:src/bar /data/tmp

this would recursively transfer all files from the directory src/bar on the machine foo into the /data/tmp/bar directory on the local machine. The files are transferred in "archive" mode, which ensures that symbolic links, devices, attributes, permissions, ownerships etc are preserved in the transfer. Additionally, compression will be used to reduce the size of data portions of the transfer.

 

rsync -avz foo:src/bar/ /data/tmp

a trailing slash on the source changes this behavior to transfer all files from the directory src/bar on the machine foo into the /data/tmp/. A trailing / on a source name means "copy the contents of this directory". Without a trailing slash it means "copy the directory". This difference becomes particularly important when using the --delete option.

You can also use rsync in local-only mode, where both the source and destination don't have a ':' in the name. In this case it behaves like an improved copy command.

 

rsync somehost.mydomain.com::

this would list all the anonymous rsync modules available on the host somehost.mydomain.com. (See the following section for more details.)

CONNECTING TO AN RSYNC SERVER

It is also possible to use rsync without using rsh or ssh as the transport. In this case you will connect to a remote rsync server running on TCP port 873.

You may establish the connection via a web proxy by setting the environment variable RSYNC_PROXY to a hostname:port pair pointing to your web proxy. Note that your web proxy's configuration must allow proxying to port 873.

Using rsync in this way is the same as using it with rsh or ssh except that:

 

o
you use a double colon :: instead of a single colon to separate the hostname from the path.
o
the remote server may print a message of the day when you connect.
o
if you specify no path name on the remote server then the list of accessible paths on the server will be shown.
o
if you specify no local destination then a listing of the specified files on the remote server is provided.

Some paths on the remote server may require authentication. If so then you will receive a password prompt when you connect. You can avoid the password prompt by setting the environment variable RSYNC_PASSWORD to the password you want to use or using the --password-file option. This may be useful when scripting rsync.

WARNING: On some systems environment variables are visible to all users. On those systems using --password-file is recommended.

RUNNING AN RSYNC SERVER

An rsync server is configured using a config file which by default is called /etc/rsyncd.conf. Please see the rsyncd.conf(5) man page for more information.

EXAMPLES

Here are some examples of how I use rsync.

To backup my wife's home directory, which consists of large MS Word files and mail folders, I use a cron job that runs

 

rsync -Cavz . arvidsjaur:backup

each night over a PPP link to a duplicate directory on my machine "arvidsjaur".

To synchronize my samba source trees I use the following Makefile targets:

 

get: 
rsync -avuzb --exclude '*~' samba:samba/ .

put: 
rsync -Cavuzb . samba:samba/

sync: get put

this allows me to sync with a CVS directory at the other end of the link. I then do cvs operations on the remote machine, which saves a lot of time as the remote cvs protocol isn't very efficient.

I mirror a directory between my "old" and "new" ftp sites with the command

 

rsync -az -e ssh --delete ~ftp/pub/samba/ nimbus:"~ftp/pub/tridge/samba"

this is launched from cron every few hours.

OPTIONS SUMMARY

Here is a short summary of the options available in rsync. Please refer to the detailed description below for a complete description.

 

 

 

 -v, --verbose               increase verbosity
 -q, --quiet                 decrease verbosity
 -c, --checksum              always checksum
 -a, --archive               archive mode
 -r, --recursive             recurse into directories
 -R, --relative              use relative path names
 -b, --backup                make backups (default ~ suffix)
     --backup-dir            make backups into this directory
     --suffix=SUFFIX         override backup suffix
 -u, --update                update only (don't overwrite newer files)
 -l, --links                 copy symlinks as symlinks
 -L, --copy-links            copy the referent of symlinks
     --copy-unsafe-links     copy links outside the source tree
     --safe-links            ignore links outside the destination tree
 -H, --hard-links            preserve hard links
 -p, --perms                 preserve permissions
 -o, --owner                 preserve owner (root only)
 -g, --group                 preserve group
 -D, --devices               preserve devices (root only)
 -t, --times                 preserve times
 -S, --sparse                handle sparse files efficiently
 -n, --dry-run               show what would have been transferred
 -W, --whole-file            copy whole files, no incremental checks
     --no-whole-file         turn off --whole-file
 -x, --one-file-system       don't cross filesystem boundaries
 -B, --block-size=SIZE       checksum blocking size (default 700)
 -e, --rsh=COMMAND           specify rsh replacement
     --rsync-path=PATH       specify path to rsync on the remote machine
 -C, --cvs-exclude           auto ignore files in the same way CVS does
     --existing              only update files that already exist
     --ignore-existing       ignore files that already exist on the receiving side
     --delete                delete files that don't exist on the sending side
     --delete-excluded       also delete excluded files on the receiving side
     --delete-after          delete after transferring, not before
     --ignore-errors         delete even if there are IO errors
     --max-delete=NUM        don't delete more than NUM files
     --partial               keep partially transferred files
     --force                 force deletion of directories even if not empty
     --numeric-ids           don't map uid/gid values by user/group name
     --timeout=TIME          set IO timeout in seconds
 -I, --ignore-times          don't exclude files that match length and time
     --size-only             only use file size when determining if a file should be transferred
     --modify-window=NUM     Timestamp window (seconds) for file match (default=0)
 -T  --temp-dir=DIR          create temporary files in directory DIR
     --compare-dest=DIR      also compare destination files relative to DIR
 -P                          equivalent to --partial --progress
 -z, --compress              compress file data
     --exclude=PATTERN       exclude files matching PATTERN
     --exclude-from=FILE     exclude patterns listed in FILE
     --include=PATTERN       don't exclude files matching PATTERN
     --include-from=FILE     don't exclude patterns listed in FILE
     --version               print version number
     --daemon                run as a rsync daemon
     --no-detach             do not detach from the parent
     --address=ADDRESS       bind to the specified address
     --config=FILE           specify alternate rsyncd.conf file
     --port=PORT             specify alternate rsyncd port number
     --blocking-io           use blocking IO for the remote shell
     --no-blocking-io        turn off --blocking-io
     --stats                 give some file transfer stats
     --progress              show progress during transfer
     --log-format=FORMAT     log file transfers using specified format
     --password-file=FILE    get password from FILE
     --bwlimit=KBPS          limit I/O bandwidth, KBytes per second
     --read-batch=PREFIX     read batch fileset starting with PREFIX
     --write-batch=PREFIX    write batch fileset starting with PREFIX
 -h, --help                  show this help screen




 

OPTIONS

rsync uses the GNU long options package. Many of the command line options have two variants, one short and one long. These are shown below, separated by commas. Some options only have a long variant. The '=' for options that take a parameter is optional; whitespace can be used instead.

 

-h, --help
Print a short help page describing the options available in rsync
--version
print the rsync version number and exit
-v, --verbose
This option increases the amount of information you are given during the transfer. By default, rsync works silently. A single -v will give you information about what files are being transferred and a brief summary at the end. Two -v flags will give you information on what files are being skipped and slightly more information at the end. More than two -v flags should only be used if you are debugging rsync.
-q, --quiet
This option decreases the amount of information you are given during the transfer, notably suppressing information messages from the remote server. This flag is useful when invoking rsync from cron.
-I, --ignore-times
Normally rsync will skip any files that are already the same length and have the same time-stamp. This option turns off this behavior.
--size-only
Normally rsync will skip any files that are already the same length and have the same time-stamp. With the --size-only option files will be skipped if they have the same size, regardless of timestamp. This is useful when starting to use rsync after using another mirroring system which may not preserve timestamps exactly.
--modify-window
When comparing two timestamps rsync treats the timestamps as being equal if they are within the value of modify_window. This is normally zero, but you may find it useful to set this to a larger value in some situations. In particular, when transferring to/from FAT filesystems which cannot represent times with a 1 second resolution this option is useful.
-c, --checksum
This forces the sender to checksum all files using a 128-bit MD4 checksum before transfer. The checksum is then explicitly checked on the receiver and any files of the same name which already exist and have the same checksum and size on the receiver are skipped. This option can be quite slow.
-a, --archive
This is equivalent to -rlptgoD. It is a quick way of saying you want recursion and want to preserve almost everything.
Note however that -a does not preserve hardlinks, because finding multiply-linked files is expensive. You must separately specify -H.
-r, --recursive
This tells rsync to copy directories recursively. If you don't specify this then rsync won't copy directories at all.
-R, --relative
Use relative paths. This means that the full path names specified on the command line are sent to the server rather than just the last parts of the filenames. This is particularly useful when you want to send several different directories at the same time. For example, if you used the command

 

 
rsync foo/bar/foo.c remote:/tmp/

 

then this would create a file called foo.c in /tmp/ on the remote machine. If instead you used

 

 
rsync -R foo/bar/foo.c remote:/tmp/

 

then a file called /tmp/foo/bar/foo.c would be created on the remote machine. The full path name is preserved.
-b, --backup
With this option preexisting destination files are renamed with a ~ extension as each file is transferred. You can control the backup suffix using the --suffix option.
--backup-dir=DIR
In combination with the --backup option, this tells rsync to store all backups in the specified directory. This is very useful for incremental backups.
--suffix=SUFFIX
This option allows you to override the default backup suffix used with the -b option. The default is a ~.
-u, --update
This forces rsync to skip any files for which the destination file already exists and has a date later than the source file.
-l, --links
When symlinks are encountered, recreate the symlink on the destination.
-L, --copy-links
When symlinks are encountered, the file that they point to is copied, rather than the symlink.
--copy-unsafe-links
This tells rsync to copy the referent of symbolic links that point outside the source tree. Absolute symlinks are also treated like ordinary files, and so are any symlinks in the source path itself when --relative is used.
--safe-links
This tells rsync to ignore any symbolic links which point outside the destination tree. All absolute symlinks are also ignored. Using this option in conjunction with --relative may give unexpected results.
-H, --hard-links
This tells rsync to recreate hard links on the remote system to be the same as the local system. Without this option hard links are treated like regular files.
Note that rsync can only detect hard links if both parts of the link are in the list of files being sent.
This option can be quite slow, so only use it if you need it.
-W, --whole-file
With this option the incremental rsync algorithm is not used and the whole file is sent as-is instead. The transfer may be faster if this option is used when the bandwidth between the source and target machines is higher than the bandwidth to disk (especially when the "disk" is actually a networked file system). This is the default when both the source and target are on the local machine.

Ця відповідь Вам допомогла?

 Роздрукувати цю статтю

Також прочитайте

Setting Up rSyncIT using FTP

Setting up rSyncIT to work with your FTP client.   You can download a variety of FTP clients to...

Full List of RSYNC options for OSX / Terminal(Advanced Users)

  Below is a full list of RSYNC commands that you can use within Apple / Mac's Terminal.app...

Using rSyncIT on Windows 7 via WebDav

WebDAV has been around for quite a while, but it¢s actually built into all versions of Windows 7....

A rSyncIT Quick Start Using FileZilla (Windows / Mac)

Here is a quick start guide for using your rSyncIT Account. This guide will take you through a...

A Quick Start - Using rSyncIT cPanel - Access WebDisk

In the email sent to you on sign up, titled "New Account Information", you will find a link to...