1rsync(1) rsync(1)
2
3
4
6 rsync — a fast, versatile, remote (and local) file-copying tool
7
9 Local: rsync [OPTION...] SRC... [DEST]
10
11 Access via remote shell:
12 Pull: rsync [OPTION...] [USER@]HOST:SRC... [DEST]
13 Push: rsync [OPTION...] SRC... [USER@]HOST:DEST
14
15 Access via rsync daemon:
16 Pull: rsync [OPTION...] [USER@]HOST::SRC... [DEST]
17 rsync [OPTION...] rsync://[USER@]HOST[:PORT]/SRC... [DEST]
18 Push: rsync [OPTION...] SRC... [USER@]HOST::DEST
19 rsync [OPTION...] SRC... rsync://[USER@]HOST[:PORT]/DEST
20
21
22 Usages with just one SRC arg and no DEST arg will list the source files
23 instead of copying.
24
26 Rsync is a fast and extraordinarily versatile file copying tool. It
27 can copy locally, to/from another host over any remote shell, or
28 to/from a remote rsync daemon. It offers a large number of options
29 that control every aspect of its behavior and permit very flexible
30 specification of the set of files to be copied. It is famous for its
31 delta-transfer algorithm, which reduces the amount of data sent over
32 the network by sending only the differences between the source files
33 and the existing files in the destination. Rsync is widely used for
34 backups and mirroring and as an improved copy command for everyday use.
35
36 Rsync finds files that need to be transferred using a "quick check"
37 algorithm (by default) that looks for files that have changed in size
38 or in last-modified time. Any changes in the other preserved
39 attributes (as requested by options) are made on the destination file
40 directly when the quick check indicates that the file’s data does not
41 need to be updated.
42
43 Some of the additional features of rsync are:
44
45 o support for copying links, devices, owners, groups, and permis‐
46 sions
47
48 o exclude and exclude-from options similar to GNU tar
49
50 o a CVS exclude mode for ignoring the same files that CVS would
51 ignore
52
53 o can use any transparent remote shell, including ssh or rsh
54
55 o does not require super-user privileges
56
57 o pipelining of file transfers to minimize latency costs
58
59 o support for anonymous or authenticated rsync daemons (ideal for
60 mirroring)
61
62
64 Rsync copies files either to or from a remote host, or locally on the
65 current host (it does not support copying files between two remote
66 hosts).
67
68 There are two different ways for rsync to contact a remote system:
69 using a remote-shell program as the transport (such as ssh or rsh) or
70 contacting an rsync daemon directly via TCP. The remote-shell trans‐
71 port is used whenever the source or destination path contains a single
72 colon (:) separator after a host specification. Contacting an rsync
73 daemon directly happens when the source or destination path contains a
74 double colon (::) separator after a host specification, OR when an
75 rsync:// URL is specified (see also the "USING RSYNC-DAEMON FEATURES
76 VIA A REMOTE-SHELL CONNECTION" section for an exception to this latter
77 rule).
78
79 As a special case, if a single source arg is specified without a desti‐
80 nation, the files are listed in an output format similar to "ls -l".
81
82 As expected, if neither the source or destination path specify a remote
83 host, the copy occurs locally (see also the --list-only option).
84
85 Rsync refers to the local side as the "client" and the remote side as
86 the "server". Don’t confuse "server" with an rsync daemon -- a daemon
87 is always a server, but a server can be either a daemon or a
88 remote-shell spawned process.
89
91 See the file README for installation instructions.
92
93 Once installed, you can use rsync to any machine that you can access
94 via a remote shell (as well as some that you can access using the rsync
95 daemon-mode protocol). For remote transfers, a modern rsync uses ssh
96 for its communications, but it may have been configured to use a dif‐
97 ferent remote shell by default, such as rsh or remsh.
98
99 You can also specify any remote shell you like, either by using the -e
100 command line option, or by setting the RSYNC_RSH environment variable.
101
102 Note that rsync must be installed on both the source and destination
103 machines.
104
106 You use rsync in the same way you use rcp. You must specify a source
107 and a destination, one of which may be remote.
108
109 Perhaps the best way to explain the syntax is with some examples:
110
111 rsync -t *.c foo:src/
112
113
114 This would transfer all files matching the pattern *.c from the current
115 directory to the directory src on the machine foo. If any of the files
116 already exist on the remote system then the rsync remote-update proto‐
117 col is used to update the file by sending only the differences. See the
118 tech report for details.
119
120 rsync -avz foo:src/bar /data/tmp
121
122
123 This would recursively transfer all files from the directory src/bar on
124 the machine foo into the /data/tmp/bar directory on the local machine.
125 The files are transferred in "archive" mode, which ensures that sym‐
126 bolic links, devices, attributes, permissions, ownerships, etc. are
127 preserved in the transfer. Additionally, compression will be used to
128 reduce the size of data portions of the transfer.
129
130 rsync -avz foo:src/bar/ /data/tmp
131
132
133 A trailing slash on the source changes this behavior to avoid creating
134 an additional directory level at the destination. You can think of a
135 trailing / on a source as meaning "copy the contents of this directory"
136 as opposed to "copy the directory by name", but in both cases the
137 attributes of the containing directory are transferred to the contain‐
138 ing directory on the destination. In other words, each of the follow‐
139 ing commands copies the files in the same way, including their setting
140 of the attributes of /dest/foo:
141
142 rsync -av /src/foo /dest
143 rsync -av /src/foo/ /dest/foo
144
145
146 Note also that host and module references don’t require a trailing
147 slash to copy the contents of the default directory. For example, both
148 of these copy the remote directory’s contents into "/dest":
149
150 rsync -av host: /dest
151 rsync -av host::module /dest
152
153
154 You can also use rsync in local-only mode, where both the source and
155 destination don’t have a ’:’ in the name. In this case it behaves like
156 an improved copy command.
157
158 Finally, you can list all the (listable) modules available from a par‐
159 ticular rsync daemon by leaving off the module name:
160
161 rsync somehost.mydomain.com::
162
163
164 See the following section for more details.
165
167 The syntax for requesting multiple files from a remote host is done by
168 specifying additional remote-host args in the same style as the first,
169 or with the hostname omitted. For instance, all these work:
170
171 rsync -av host:file1 :file2 host:file{3,4} /dest/
172 rsync -av host::modname/file{1,2} host::modname/file3 /dest/
173 rsync -av host::modname/file1 ::modname/file{3,4}
174
175
176 Older versions of rsync required using quoted spaces in the SRC, like
177 these examples:
178
179 rsync -av host:'dir1/file1 dir2/file2' /dest
180 rsync host::'modname/dir1/file1 modname/dir2/file2' /dest
181
182
183 This word-splitting still works (by default) in the latest rsync, but
184 is not as easy to use as the first method.
185
186 If you need to transfer a filename that contains whitespace, you can
187 either specify the --protect-args (-s) option, or you’ll need to escape
188 the whitespace in a way that the remote shell will understand. For
189 instance:
190
191 rsync -av host:'file\ name\ with\ spaces' /dest
192
193
195 It is also possible to use rsync without a remote shell as the trans‐
196 port. In this case you will directly connect to a remote rsync daemon,
197 typically using TCP port 873. (This obviously requires the daemon to
198 be running on the remote system, so refer to the STARTING AN RSYNC DAE‐
199 MON TO ACCEPT CONNECTIONS section below for information on that.)
200
201 Using rsync in this way is the same as using it with a remote shell
202 except that:
203
204 o you either use a double colon :: instead of a single colon to
205 separate the hostname from the path, or you use an rsync:// URL.
206
207 o the first word of the "path" is actually a module name.
208
209 o the remote daemon may print a message of the day when you con‐
210 nect.
211
212 o if you specify no path name on the remote daemon then the list
213 of accessible paths on the daemon will be shown.
214
215 o if you specify no local destination then a listing of the speci‐
216 fied files on the remote daemon is provided.
217
218 o you must not specify the --rsh (-e) option.
219
220
221 An example that copies all the files in a remote module named "src":
222
223 rsync -av host::src /dest
224
225
226 Some modules on the remote daemon may require authentication. If so,
227 you will receive a password prompt when you connect. You can avoid the
228 password prompt by setting the environment variable RSYNC_PASSWORD to
229 the password you want to use or using the --password-file option. This
230 may be useful when scripting rsync.
231
232 WARNING: On some systems environment variables are visible to all
233 users. On those systems using --password-file is recommended.
234
235 You may establish the connection via a web proxy by setting the envi‐
236 ronment variable RSYNC_PROXY to a hostname:port pair pointing to your
237 web proxy. Note that your web proxy’s configuration must support proxy
238 connections to port 873.
239
240 You may also establish a daemon connection using a program as a proxy
241 by setting the environment variable RSYNC_CONNECT_PROG to the commands
242 you wish to run in place of making a direct socket connection. The
243 string may contain the escape "%H" to represent the hostname specified
244 in the rsync command (so use "%%" if you need a single "%" in your
245 string). For example:
246
247 export RSYNC_CONNECT_PROG='ssh proxyhost nc %H 873'
248 rsync -av targethost1::module/src/ /dest/
249 rsync -av rsync:://targethost2/module/src/ /dest/
250
251
252 The command specified above uses ssh to run nc (netcat) on a proxyhost,
253 which forwards all data to port 873 (the rsync daemon) on the targeth‐
254 ost (%H).
255
257 It is sometimes useful to use various features of an rsync daemon (such
258 as named modules) without actually allowing any new socket connections
259 into a system (other than what is already required to allow
260 remote-shell access). Rsync supports connecting to a host using a
261 remote shell and then spawning a single-use "daemon" server that
262 expects to read its config file in the home dir of the remote user.
263 This can be useful if you want to encrypt a daemon-style transfer’s
264 data, but since the daemon is started up fresh by the remote user, you
265 may not be able to use features such as chroot or change the uid used
266 by the daemon. (For another way to encrypt a daemon transfer, consider
267 using ssh to tunnel a local port to a remote machine and configure a
268 normal rsync daemon on that remote host to only allow connections from
269 "localhost".)
270
271 From the user’s perspective, a daemon transfer via a remote-shell con‐
272 nection uses nearly the same command-line syntax as a normal rsync-dae‐
273 mon transfer, with the only exception being that you must explicitly
274 set the remote shell program on the command-line with the --rsh=COMMAND
275 option. (Setting the RSYNC_RSH in the environment will not turn on
276 this functionality.) For example:
277
278 rsync -av --rsh=ssh host::module /dest
279
280
281 If you need to specify a different remote-shell user, keep in mind that
282 the user@ prefix in front of the host is specifying the rsync-user
283 value (for a module that requires user-based authentication). This
284 means that you must give the ’-l user’ option to ssh when specifying
285 the remote-shell, as in this example that uses the short version of the
286 --rsh option:
287
288 rsync -av -e "ssh -l ssh-user" rsync-user@host::module /dest
289
290
291 The "ssh-user" will be used at the ssh level; the "rsync-user" will be
292 used to log-in to the "module".
293
295 In order to connect to an rsync daemon, the remote system needs to have
296 a daemon already running (or it needs to have configured something like
297 inetd to spawn an rsync daemon for incoming connections on a particular
298 port). For full information on how to start a daemon that will han‐
299 dling incoming socket connections, see the rsyncd.conf(5) man page --
300 that is the config file for the daemon, and it contains the full
301 details for how to run the daemon (including stand-alone and inetd con‐
302 figurations).
303
304 If you’re using one of the remote-shell transports for the transfer,
305 there is no need to manually start an rsync daemon.
306
308 Here are some examples of how I use rsync.
309
310 To backup my wife’s home directory, which consists of large MS Word
311 files and mail folders, I use a cron job that runs
312
313 rsync -Cavz . arvidsjaur:backup
314
315
316 each night over a PPP connection to a duplicate directory on my machine
317 "arvidsjaur".
318
319 To synchronize my samba source trees I use the following Makefile tar‐
320 gets:
321
322 get:
323 rsync -avuzb --exclude '*~' samba:samba/ .
324 put:
325 rsync -Cavuzb . samba:samba/
326 sync: get put
327
328
329 this allows me to sync with a CVS directory at the other end of the
330 connection. I then do CVS operations on the remote machine, which saves
331 a lot of time as the remote CVS protocol isn’t very efficient.
332
333 I mirror a directory between my "old" and "new" ftp sites with the com‐
334 mand:
335
336 rsync -az -e ssh --delete ~ftp/pub/samba nimbus:"~ftp/pub/tridge"
337
338 This is launched from cron every few hours.
339
341 Here is a short summary of the options available in rsync. Please refer
342 to the detailed description below for a complete description.
343
344 -v, --verbose increase verbosity
345 -q, --quiet suppress non-error messages
346 --no-motd suppress daemon-mode MOTD (see caveat)
347 -c, --checksum skip based on checksum, not mod-time & size
348 -a, --archive archive mode; equals -rlptgoD (no -H,-A,-X)
349 --no-OPTION turn off an implied OPTION (e.g. --no-D)
350 -r, --recursive recurse into directories
351 -R, --relative use relative path names
352 --no-implied-dirs don't send implied dirs with --relative
353 -b, --backup make backups (see --suffix & --backup-dir)
354 --backup-dir=DIR make backups into hierarchy based in DIR
355 --suffix=SUFFIX backup suffix (default ~ w/o --backup-dir)
356 -u, --update skip files that are newer on the receiver
357 --inplace update destination files in-place
358 --append append data onto shorter files
359 --append-verify --append w/old data in file checksum
360 -d, --dirs transfer directories without recursing
361 -l, --links copy symlinks as symlinks
362 -L, --copy-links transform symlink into referent file/dir
363 --copy-unsafe-links only "unsafe" symlinks are transformed
364 --safe-links ignore symlinks that point outside the tree
365 -k, --copy-dirlinks transform symlink to dir into referent dir
366 -K, --keep-dirlinks treat symlinked dir on receiver as dir
367 -H, --hard-links preserve hard links
368 -p, --perms preserve permissions
369 -E, --executability preserve executability
370 --chmod=CHMOD affect file and/or directory permissions
371 -A, --acls preserve ACLs (implies -p)
372 -X, --xattrs preserve extended attributes
373 -o, --owner preserve owner (super-user only)
374 -g, --group preserve group
375 --devices preserve device files (super-user only)
376 --specials preserve special files
377 -D same as --devices --specials
378 -t, --times preserve modification times
379 -O, --omit-dir-times omit directories from --times
380 --super receiver attempts super-user activities
381 --fake-super store/recover privileged attrs using xattrs
382 -S, --sparse handle sparse files efficiently
383 -n, --dry-run perform a trial run with no changes made
384 -W, --whole-file copy files whole (w/o delta-xfer algorithm)
385 -x, --one-file-system don't cross filesystem boundaries
386 -B, --block-size=SIZE force a fixed checksum block-size
387 -e, --rsh=COMMAND specify the remote shell to use
388 --rsync-path=PROGRAM specify the rsync to run on remote machine
389 --existing skip creating new files on receiver
390 --ignore-existing skip updating files that exist on receiver
391 --remove-source-files sender removes synchronized files (non-dir)
392 --del an alias for --delete-during
393 --delete delete extraneous files from dest dirs
394 --delete-before receiver deletes before transfer (default)
395 --delete-during receiver deletes during xfer, not before
396 --delete-delay find deletions during, delete after
397 --delete-after receiver deletes after transfer, not before
398 --delete-excluded also delete excluded files from dest dirs
399 --ignore-errors delete even if there are I/O errors
400 --force force deletion of dirs even if not empty
401 --max-delete=NUM don't delete more than NUM files
402 --max-size=SIZE don't transfer any file larger than SIZE
403 --min-size=SIZE don't transfer any file smaller than SIZE
404 --partial keep partially transferred files
405 --partial-dir=DIR put a partially transferred file into DIR
406 --delay-updates put all updated files into place at end
407 -m, --prune-empty-dirs prune empty directory chains from file-list
408 --numeric-ids don't map uid/gid values by user/group name
409 --timeout=SECONDS set I/O timeout in seconds
410 --contimeout=SECONDS set daemon connection timeout in seconds
411 -I, --ignore-times don't skip files that match size and time
412 --size-only skip files that match in size
413 --modify-window=NUM compare mod-times with reduced accuracy
414 -T, --temp-dir=DIR create temporary files in directory DIR
415 -y, --fuzzy find similar file for basis if no dest file
416 --compare-dest=DIR also compare received files relative to DIR
417 --copy-dest=DIR ... and include copies of unchanged files
418 --link-dest=DIR hardlink to files in DIR when unchanged
419 -z, --compress compress file data during the transfer
420 --compress-level=NUM explicitly set compression level
421 --skip-compress=LIST skip compressing files with suffix in LIST
422 -C, --cvs-exclude auto-ignore files in the same way CVS does
423 -f, --filter=RULE add a file-filtering RULE
424 -F same as --filter='dir-merge /.rsync-filter'
425 repeated: --filter='- .rsync-filter'
426 --exclude=PATTERN exclude files matching PATTERN
427 --exclude-from=FILE read exclude patterns from FILE
428 --include=PATTERN don't exclude files matching PATTERN
429 --include-from=FILE read include patterns from FILE
430 --files-from=FILE read list of source-file names from FILE
431 -0, --from0 all *from/filter files are delimited by 0s
432 -s, --protect-args no space-splitting; wildcard chars only
433 --address=ADDRESS bind address for outgoing socket to daemon
434 --port=PORT specify double-colon alternate port number
435 --sockopts=OPTIONS specify custom TCP options
436 --blocking-io use blocking I/O for the remote shell
437 --stats give some file-transfer stats
438 -8, --8-bit-output leave high-bit chars unescaped in output
439 -h, --human-readable output numbers in a human-readable format
440 --progress show progress during transfer
441 -P same as --partial --progress
442 -i, --itemize-changes output a change-summary for all updates
443 --out-format=FORMAT output updates using the specified FORMAT
444 --log-file=FILE log what we're doing to the specified FILE
445 --log-file-format=FMT log updates using the specified FMT
446 --password-file=FILE read daemon-access password from FILE
447 --list-only list the files instead of copying them
448 --bwlimit=KBPS limit I/O bandwidth; KBytes per second
449 --write-batch=FILE write a batched update to FILE
450 --only-write-batch=FILE like --write-batch but w/o updating dest
451 --read-batch=FILE read a batched update from FILE
452 --protocol=NUM force an older protocol version to be used
453 --iconv=CONVERT_SPEC request charset conversion of filenames
454 --checksum-seed=NUM set block/file checksum seed (advanced)
455 -4, --ipv4 prefer IPv4
456 -6, --ipv6 prefer IPv6
457 --version print version number
458 (-h) --help show this help (see below for -h comment)
459
460
461 Rsync can also be run as a daemon, in which case the following options
462 are accepted:
463
464 --daemon run as an rsync daemon
465 --address=ADDRESS bind to the specified address
466 --bwlimit=KBPS limit I/O bandwidth; KBytes per second
467 --config=FILE specify alternate rsyncd.conf file
468 --no-detach do not detach from the parent
469 --port=PORT listen on alternate port number
470 --log-file=FILE override the "log file" setting
471 --log-file-format=FMT override the "log format" setting
472 --sockopts=OPTIONS specify custom TCP options
473 -v, --verbose increase verbosity
474 -4, --ipv4 prefer IPv4
475 -6, --ipv6 prefer IPv6
476 -h, --help show this help (if used after --daemon)
477
478
480 rsync uses the GNU long options package. Many of the command line
481 options have two variants, one short and one long. These are shown
482 below, separated by commas. Some options only have a long variant. The
483 ’=’ for options that take a parameter is optional; whitespace can be
484 used instead.
485
486 --help Print a short help page describing the options available in
487 rsync and exit. For backward-compatibility with older versions
488 of rsync, the help will also be output if you use the -h option
489 without any other args.
490
491 --version
492 print the rsync version number and exit.
493
494 -v, --verbose
495 This option increases the amount of information you are given
496 during the transfer. By default, rsync works silently. A single
497 -v will give you information about what files are being trans‐
498 ferred and a brief summary at the end. Two -v options will give
499 you information on what files are being skipped and slightly
500 more information at the end. More than two -v options should
501 only be used if you are debugging rsync.
502
503 Note that the names of the transferred files that are output are
504 done using a default --out-format of "%n%L", which tells you
505 just the name of the file and, if the item is a link, where it
506 points. At the single -v level of verbosity, this does not men‐
507 tion when a file gets its attributes changed. If you ask for an
508 itemized list of changed attributes (either --itemize-changes or
509 adding "%i" to the --out-format setting), the output (on the
510 client) increases to mention all items that are changed in any
511 way. See the --out-format option for more details.
512
513 -q, --quiet
514 This option decreases the amount of information you are given
515 during the transfer, notably suppressing information messages
516 from the remote server. This option is useful when invoking
517 rsync from cron.
518
519 --no-motd
520 This option affects the information that is output by the client
521 at the start of a daemon transfer. This suppresses the mes‐
522 sage-of-the-day (MOTD) text, but it also affects the list of
523 modules that the daemon sends in response to the "rsync host::"
524 request (due to a limitation in the rsync protocol), so omit
525 this option if you want to request the list of modules from the
526 daemon.
527
528 -I, --ignore-times
529 Normally rsync will skip any files that are already the same
530 size and have the same modification timestamp. This option
531 turns off this "quick check" behavior, causing all files to be
532 updated.
533
534 --size-only
535 This modifies rsync’s "quick check" algorithm for finding files
536 that need to be transferred, changing it from the default of
537 transferring files with either a changed size or a changed
538 last-modified time to just looking for files that have changed
539 in size. This is useful when starting to use rsync after using
540 another mirroring system which may not preserve timestamps
541 exactly.
542
543 --modify-window
544 When comparing two timestamps, rsync treats the timestamps as
545 being equal if they differ by no more than the modify-window
546 value. This is normally 0 (for an exact match), but you may
547 find it useful to set this to a larger value in some situations.
548 In particular, when transferring to or from an MS Windows FAT
549 filesystem (which represents times with a 2-second resolution),
550 --modify-window=1 is useful (allowing times to differ by up to 1
551 second).
552
553 -c, --checksum
554 This changes the way rsync checks if the files have been changed
555 and are in need of a transfer. Without this option, rsync uses
556 a "quick check" that (by default) checks if each file’s size and
557 time of last modification match between the sender and receiver.
558 This option changes this to compare a 128-bit checksum for each
559 file that has a matching size. Generating the checksums means
560 that both sides will expend a lot of disk I/O reading all the
561 data in the files in the transfer (and this is prior to any
562 reading that will be done to transfer changed files), so this
563 can slow things down significantly.
564
565 The sending side generates its checksums while it is doing the
566 file-system scan that builds the list of the available files.
567 The receiver generates its checksums when it is scanning for
568 changed files, and will checksum any file that has the same size
569 as the corresponding sender’s file: files with either a changed
570 size or a changed checksum are selected for transfer.
571
572 Note that rsync always verifies that each transferred file was
573 correctly reconstructed on the receiving side by checking a
574 whole-file checksum that is generated as the file is trans‐
575 ferred, but that automatic after-the-transfer verification has
576 nothing to do with this option’s before-the-transfer "Does this
577 file need to be updated?" check.
578
579 For protocol 30 and beyond (first supported in 3.0.0), the
580 checksum used is MD5. For older protocols, the checksum used is
581 MD4.
582
583 -a, --archive
584 This is equivalent to -rlptgoD. It is a quick way of saying you
585 want recursion and want to preserve almost everything (with -H
586 being a notable omission). The only exception to the above
587 equivalence is when --files-from is specified, in which case -r
588 is not implied.
589
590 Note that -a does not preserve hardlinks, because finding multi‐
591 ply-linked files is expensive. You must separately specify -H.
592
593 --no-OPTION
594 You may turn off one or more implied options by prefixing the
595 option name with "no-". Not all options may be prefixed with a
596 "no-": only options that are implied by other options (e.g.
597 --no-D, --no-perms) or have different defaults in various cir‐
598 cumstances (e.g. --no-whole-file, --no-blocking-io, --no-dirs).
599 You may specify either the short or the long option name after
600 the "no-" prefix (e.g. --no-R is the same as --no-relative).
601
602 For example: if you want to use -a (--archive) but don’t want -o
603 (--owner), instead of converting -a into -rlptgD, you could
604 specify -a --no-o (or -a --no-owner).
605
606 The order of the options is important: if you specify --no-r
607 -a, the -r option would end up being turned on, the opposite of
608 -a --no-r. Note also that the side-effects of the --files-from
609 option are NOT positional, as it affects the default state of
610 several options and slightly changes the meaning of -a (see the
611 --files-from option for more details).
612
613 -r, --recursive
614 This tells rsync to copy directories recursively. See also
615 --dirs (-d).
616
617 Beginning with rsync 3.0.0, the recursive algorithm used is now
618 an incremental scan that uses much less memory than before and
619 begins the transfer after the scanning of the first few directo‐
620 ries have been completed. This incremental scan only affects
621 our recursion algorithm, and does not change a non-recursive
622 transfer. It is also only possible when both ends of the trans‐
623 fer are at least version 3.0.0.
624
625 Some options require rsync to know the full file list, so these
626 options disable the incremental recursion mode. These include:
627 --delete-before, --delete-after, --prune-empty-dirs, and
628 --delay-updates. Because of this, the default delete mode when
629 you specify --delete is now --delete-during when both ends of
630 the connection are at least 3.0.0 (use --del or --delete-during
631 to request this improved deletion mode explicitly). See also
632 the --delete-delay option that is a better choice than using
633 --delete-after.
634
635 Incremental recursion can be disabled using the --no-inc-recur‐
636 sive option or its shorter --no-i-r alias.
637
638 -R, --relative
639 Use relative paths. This means that the full path names speci‐
640 fied on the command line are sent to the server rather than just
641 the last parts of the filenames. This is particularly useful
642 when you want to send several different directories at the same
643 time. For example, if you used this command:
644
645 rsync -av /foo/bar/baz.c remote:/tmp/
646
647
648 ... this would create a file named baz.c in /tmp/ on the remote
649 machine. If instead you used
650
651 rsync -avR /foo/bar/baz.c remote:/tmp/
652
653
654 then a file named /tmp/foo/bar/baz.c would be created on the
655 remote machine, preserving its full path. These extra path ele‐
656 ments are called "implied directories" (i.e. the "foo" and the
657 "foo/bar" directories in the above example).
658
659 Beginning with rsync 3.0.0, rsync always sends these implied
660 directories as real directories in the file list, even if a path
661 element is really a symlink on the sending side. This prevents
662 some really unexpected behaviors when copying the full path of a
663 file that you didn’t realize had a symlink in its path. If you
664 want to duplicate a server-side symlink, include both the sym‐
665 link via its path, and referent directory via its real path. If
666 you’re dealing with an older rsync on the sending side, you may
667 need to use the --no-implied-dirs option.
668
669 It is also possible to limit the amount of path information that
670 is sent as implied directories for each path you specify. With
671 a modern rsync on the sending side (beginning with 2.6.7), you
672 can insert a dot and a slash into the source path, like this:
673
674 rsync -avR /foo/./bar/baz.c remote:/tmp/
675
676
677 That would create /tmp/bar/baz.c on the remote machine. (Note
678 that the dot must be followed by a slash, so "/foo/." would not
679 be abbreviated.) For older rsync versions, you would need to
680 use a chdir to limit the source path. For example, when pushing
681 files:
682
683 (cd /foo; rsync -avR bar/baz.c remote:/tmp/)
684
685
686 (Note that the parens put the two commands into a sub-shell, so
687 that the "cd" command doesn’t remain in effect for future com‐
688 mands.) If you’re pulling files from an older rsync, use this
689 idiom (but only for a non-daemon transfer):
690
691 rsync -avR --rsync-path="cd /foo; rsync" \
692 remote:bar/baz.c /tmp/
693
694
695 --no-implied-dirs
696 This option affects the default behavior of the --relative
697 option. When it is specified, the attributes of the implied
698 directories from the source names are not included in the trans‐
699 fer. This means that the corresponding path elements on the
700 destination system are left unchanged if they exist, and any
701 missing implied directories are created with default attributes.
702 This even allows these implied path elements to have big differ‐
703 ences, such as being a symlink to a directory on the receiving
704 side.
705
706 For instance, if a command-line arg or a files-from entry told
707 rsync to transfer the file "path/foo/file", the directories
708 "path" and "path/foo" are implied when --relative is used. If
709 "path/foo" is a symlink to "bar" on the destination system, the
710 receiving rsync would ordinarily delete "path/foo", recreate it
711 as a directory, and receive the file into the new directory.
712 With --no-implied-dirs, the receiving rsync updates
713 "path/foo/file" using the existing path elements, which means
714 that the file ends up being created in "path/bar". Another way
715 to accomplish this link preservation is to use the
716 --keep-dirlinks option (which will also affect symlinks to
717 directories in the rest of the transfer).
718
719 When pulling files from an rsync older than 3.0.0, you may need
720 to use this option if the sending side has a symlink in the path
721 you request and you wish the implied directories to be trans‐
722 ferred as normal directories.
723
724 -b, --backup
725 With this option, preexisting destination files are renamed as
726 each file is transferred or deleted. You can control where the
727 backup file goes and what (if any) suffix gets appended using
728 the --backup-dir and --suffix options.
729
730 Note that if you don’t specify --backup-dir, (1) the
731 --omit-dir-times option will be implied, and (2) if --delete is
732 also in effect (without --delete-excluded), rsync will add a
733 "protect" filter-rule for the backup suffix to the end of all
734 your existing excludes (e.g. -f "P *~"). This will prevent pre‐
735 viously backed-up files from being deleted. Note that if you
736 are supplying your own filter rules, you may need to manually
737 insert your own exclude/protect rule somewhere higher up in the
738 list so that it has a high enough priority to be effective
739 (e.g., if your rules specify a trailing inclusion/exclusion of
740 ’*’, the auto-added rule would never be reached).
741
742 --backup-dir=DIR
743 In combination with the --backup option, this tells rsync to
744 store all backups in the specified directory on the receiving
745 side. This can be used for incremental backups. You can addi‐
746 tionally specify a backup suffix using the --suffix option (oth‐
747 erwise the files backed up in the specified directory will keep
748 their original filenames).
749
750 Note that if you specify a relative path, the backup directory
751 will be relative to the destination directory, so you probably
752 want to specify either an absolute path or a path that starts
753 with "../". If an rsync daemon is the receiver, the backup dir
754 cannot go outside the module’s path hierarchy, so take extra
755 care not to delete it or copy into it.
756
757 --suffix=SUFFIX
758 This option allows you to override the default backup suffix
759 used with the --backup (-b) option. The default suffix is a ~ if
760 no --backup-dir was specified, otherwise it is an empty string.
761
762 -u, --update
763 This forces rsync to skip any files which exist on the destina‐
764 tion and have a modified time that is newer than the source
765 file. (If an existing destination file has a modification time
766 equal to the source file’s, it will be updated if the sizes are
767 different.)
768
769 Note that this does not affect the copying of symlinks or other
770 special files. Also, a difference of file format between the
771 sender and receiver is always considered to be important enough
772 for an update, no matter what date is on the objects. In other
773 words, if the source has a directory where the destination has a
774 file, the transfer would occur regardless of the timestamps.
775
776 This option is a transfer rule, not an exclude, so it doesn’t
777 affect the data that goes into the file-lists, and thus it
778 doesn’t affect deletions. It just limits the files that the
779 receiver requests to be transferred.
780
781 --inplace
782 This option changes how rsync transfers a file when its data
783 needs to be updated: instead of the default method of creating a
784 new copy of the file and moving it into place when it is com‐
785 plete, rsync instead writes the updated data directly to the
786 destination file.
787
788 This has several effects:
789
790 o Hard links are not broken. This means the new data will
791 be visible through other hard links to the destination
792 file. Moreover, attempts to copy differing source files
793 onto a multiply-linked destination file will result in a
794 "tug of war" with the destination data changing back and
795 forth.
796
797 o In-use binaries cannot be updated (either the OS will
798 prevent this from happening, or binaries that attempt to
799 swap-in their data will misbehave or crash).
800
801 o The file’s data will be in an inconsistent state during
802 the transfer and will be left that way if the transfer is
803 interrupted or if an update fails.
804
805 o A file that rsync cannot write to cannot be updated.
806 While a super user can update any file, a normal user
807 needs to be granted write permission for the open of the
808 file for writing to be successful.
809
810 o The efficiency of rsync’s delta-transfer algorithm may be
811 reduced if some data in the destination file is overwrit‐
812 ten before it can be copied to a position later in the
813 file. This does not apply if you use --backup, since
814 rsync is smart enough to use the backup file as the basis
815 file for the transfer.
816
817
818 WARNING: you should not use this option to update files that are
819 being accessed by others, so be careful when choosing to use
820 this for a copy.
821
822 This option is useful for transferring large files with
823 block-based changes or appended data, and also on systems that
824 are disk bound, not network bound. It can also help keep a
825 copy-on-write filesystem snapshot from diverging the entire con‐
826 tents of a file that only has minor changes.
827
828 The option implies --partial (since an interrupted transfer does
829 not delete the file), but conflicts with --partial-dir and
830 --delay-updates. Prior to rsync 2.6.4 --inplace was also incom‐
831 patible with --compare-dest and --link-dest.
832
833 --append
834 This causes rsync to update a file by appending data onto the
835 end of the file, which presumes that the data that already
836 exists on the receiving side is identical with the start of the
837 file on the sending side. If a file needs to be transferred and
838 its size on the receiver is the same or longer than the size on
839 the sender, the file is skipped. This does not interfere with
840 the updating of a file’s non-content attributes (e.g. permis‐
841 sions, ownership, etc.) when the file does not need to be trans‐
842 ferred, nor does it affect the updating of any non-regular
843 files. Implies --inplace, but does not conflict with --sparse
844 (since it is always extending a file’s length).
845
846 --append-verify
847 This works just like the --append option, but the existing data
848 on the receiving side is included in the full-file checksum ver‐
849 ification step, which will cause a file to be resent if the
850 final verification step fails (rsync uses a normal, non-append‐
851 ing --inplace transfer for the resend).
852
853 Note: prior to rsync 3.0.0, the --append option worked like
854 --append-verify, so if you are interacting with an older rsync
855 (or the transfer is using a protocol prior to 30), specifying
856 either append option will initiate an --append-verify transfer.
857
858 -d, --dirs
859 Tell the sending side to include any directories that are
860 encountered. Unlike --recursive, a directory’s contents are not
861 copied unless the directory name specified is "." or ends with a
862 trailing slash (e.g. ".", "dir/.", "dir/", etc.). Without this
863 option or the --recursive option, rsync will skip all directo‐
864 ries it encounters (and output a message to that effect for each
865 one). If you specify both --dirs and --recursive, --recursive
866 takes precedence.
867
868 The --dirs option is implied by the --files-from option or the
869 --list-only option (including an implied --list-only usage) if
870 --recursive wasn’t specified (so that directories are seen in
871 the listing). Specify --no-dirs (or --no-d) if you want to turn
872 this off.
873
874 There is also a backward-compatibility helper option, --old-dirs
875 (or --old-d) that tells rsync to use a hack of "-r
876 --exclude=’/*/*’" to get an older rsync to list a single direc‐
877 tory without recursing.
878
879 -l, --links
880 When symlinks are encountered, recreate the symlink on the des‐
881 tination.
882
883 -L, --copy-links
884 When symlinks are encountered, the item that they point to (the
885 referent) is copied, rather than the symlink. In older versions
886 of rsync, this option also had the side-effect of telling the
887 receiving side to follow symlinks, such as symlinks to directo‐
888 ries. In a modern rsync such as this one, you’ll need to spec‐
889 ify --keep-dirlinks (-K) to get this extra behavior. The only
890 exception is when sending files to an rsync that is too old to
891 understand -K -- in that case, the -L option will still have the
892 side-effect of -K on that older receiving rsync.
893
894 --copy-unsafe-links
895 This tells rsync to copy the referent of symbolic links that
896 point outside the copied tree. Absolute symlinks are also
897 treated like ordinary files, and so are any symlinks in the
898 source path itself when --relative is used. This option has no
899 additional effect if --copy-links was also specified.
900
901 --safe-links
902 This tells rsync to ignore any symbolic links which point out‐
903 side the copied tree. All absolute symlinks are also ignored.
904 Using this option in conjunction with --relative may give unex‐
905 pected results.
906
907 -k, --copy-dirlinks
908 This option causes the sending side to treat a symlink to a
909 directory as though it were a real directory. This is useful if
910 you don’t want symlinks to non-directories to be affected, as
911 they would be using --copy-links.
912
913 Without this option, if the sending side has replaced a direc‐
914 tory with a symlink to a directory, the receiving side will
915 delete anything that is in the way of the new symlink, including
916 a directory hierarchy (as long as --force or --delete is in
917 effect).
918
919 See also --keep-dirlinks for an analogous option for the receiv‐
920 ing side.
921
922 --copy-dirlinks applies to all symlinks to directories in the
923 source. If you want to follow only a few specified symlinks, a
924 trick you can use is to pass them as additional source args with
925 a trailing slash, using --relative to make the paths match up
926 right. For example:
927
928 rsync -r --relative src/./ src/./follow-me/ dest/
929
930
931 This works because rsync calls lstat(2) on the source arg as
932 given, and the trailing slash makes lstat(2) follow the symlink,
933 giving rise to a directory in the file-list which overrides the
934 symlink found during the scan of "src/./".
935
936 -K, --keep-dirlinks
937 This option causes the receiving side to treat a symlink to a
938 directory as though it were a real directory, but only if it
939 matches a real directory from the sender. Without this option,
940 the receiver’s symlink would be deleted and replaced with a real
941 directory.
942
943 For example, suppose you transfer a directory "foo" that con‐
944 tains a file "file", but "foo" is a symlink to directory "bar"
945 on the receiver. Without --keep-dirlinks, the receiver deletes
946 symlink "foo", recreates it as a directory, and receives the
947 file into the new directory. With --keep-dirlinks, the receiver
948 keeps the symlink and "file" ends up in "bar".
949
950 One note of caution: if you use --keep-dirlinks, you must trust
951 all the symlinks in the copy! If it is possible for an
952 untrusted user to create their own symlink to any directory, the
953 user could then (on a subsequent copy) replace the symlink with
954 a real directory and affect the content of whatever directory
955 the symlink references. For backup copies, you are better off
956 using something like a bind mount instead of a symlink to modify
957 your receiving hierarchy.
958
959 See also --copy-dirlinks for an analogous option for the sending
960 side.
961
962 -H, --hard-links
963 This tells rsync to look for hard-linked files in the source and
964 link together the corresponding files on the destination. With‐
965 out this option, hard-linked files in the source are treated as
966 though they were separate files.
967
968 This option does NOT necessarily ensure that the pattern of hard
969 links on the destination exactly matches that on the source.
970 Cases in which the destination may end up with extra hard links
971 include the following:
972
973 o If the destination contains extraneous hard-links (more
974 linking than what is present in the source file list),
975 the copying algorithm will not break them explicitly.
976 However, if one or more of the paths have content differ‐
977 ences, the normal file-update process will break those
978 extra links (unless you are using the --inplace option).
979
980 o If you specify a --link-dest directory that contains hard
981 links, the linking of the destination files against the
982 --link-dest files can cause some paths in the destination
983 to become linked together due to the --link-dest associa‐
984 tions.
985
986
987 Note that rsync can only detect hard links between files that
988 are inside the transfer set. If rsync updates a file that has
989 extra hard-link connections to files outside the transfer, that
990 linkage will be broken. If you are tempted to use the --inplace
991 option to avoid this breakage, be very careful that you know how
992 your files are being updated so that you are certain that no
993 unintended changes happen due to lingering hard links (and see
994 the --inplace option for more caveats).
995
996 If incremental recursion is active (see --recursive), rsync may
997 transfer a missing hard-linked file before it finds that another
998 link for that contents exists elsewhere in the hierarchy. This
999 does not affect the accuracy of the transfer (i.e. which files
1000 are hard-linked together), just its efficiency (i.e. copying the
1001 data for a new, early copy of a hard-linked file that could have
1002 been found later in the transfer in another member of the
1003 hard-linked set of files). One way to avoid this inefficiency
1004 is to disable incremental recursion using the --no-inc-recursive
1005 option.
1006
1007 -p, --perms
1008 This option causes the receiving rsync to set the destination
1009 permissions to be the same as the source permissions. (See also
1010 the --chmod option for a way to modify what rsync considers to
1011 be the source permissions.)
1012
1013 When this option is off, permissions are set as follows:
1014
1015 o Existing files (including updated files) retain their
1016 existing permissions, though the --executability option
1017 might change just the execute permission for the file.
1018
1019 o New files get their "normal" permission bits set to the
1020 source file’s permissions masked with the receiving
1021 directory’s default permissions (either the receiving
1022 process’s umask, or the permissions specified via the
1023 destination directory’s default ACL), and their special
1024 permission bits disabled except in the case where a new
1025 directory inherits a setgid bit from its parent direc‐
1026 tory.
1027
1028
1029 Thus, when --perms and --executability are both disabled,
1030 rsync’s behavior is the same as that of other file-copy utili‐
1031 ties, such as cp(1) and tar(1).
1032
1033 In summary: to give destination files (both old and new) the
1034 source permissions, use --perms. To give new files the destina‐
1035 tion-default permissions (while leaving existing files
1036 unchanged), make sure that the --perms option is off and use
1037 --chmod=ugo=rwX (which ensures that all non-masked bits get
1038 enabled). If you’d care to make this latter behavior easier to
1039 type, you could define a popt alias for it, such as putting this
1040 line in the file ~/.popt (the following defines the -Z option,
1041 and includes --no-g to use the default group of the destination
1042 dir):
1043
1044 rsync alias -Z --no-p --no-g --chmod=ugo=rwX
1045
1046
1047 You could then use this new option in a command such as this
1048 one:
1049
1050 rsync -avZ src/ dest/
1051
1052
1053 (Caveat: make sure that -a does not follow -Z, or it will
1054 re-enable the two "--no-*" options mentioned above.)
1055
1056 The preservation of the destination’s setgid bit on newly-cre‐
1057 ated directories when --perms is off was added in rsync 2.6.7.
1058 Older rsync versions erroneously preserved the three special
1059 permission bits for newly-created files when --perms was off,
1060 while overriding the destination’s setgid bit setting on a
1061 newly-created directory. Default ACL observance was added to
1062 the ACL patch for rsync 2.6.7, so older (or non-ACL-enabled)
1063 rsyncs use the umask even if default ACLs are present. (Keep in
1064 mind that it is the version of the receiving rsync that affects
1065 these behaviors.)
1066
1067 -E, --executability
1068 This option causes rsync to preserve the executability (or
1069 non-executability) of regular files when --perms is not enabled.
1070 A regular file is considered to be executable if at least one
1071 ’x’ is turned on in its permissions. When an existing destina‐
1072 tion file’s executability differs from that of the corresponding
1073 source file, rsync modifies the destination file’s permissions
1074 as follows:
1075
1076 o To make a file non-executable, rsync turns off all its
1077 ’x’ permissions.
1078
1079 o To make a file executable, rsync turns on each ’x’ per‐
1080 mission that has a corresponding ’r’ permission enabled.
1081
1082
1083 If --perms is enabled, this option is ignored.
1084
1085 -A, --acls
1086 This option causes rsync to update the destination ACLs to be
1087 the same as the source ACLs. The option also implies --perms.
1088
1089 The source and destination systems must have compatible ACL
1090 entries for this option to work properly. See the --fake-super
1091 option for a way to backup and restore ACLs that are not compat‐
1092 ible.
1093
1094 -X, --xattrs
1095 This option causes rsync to update the destination extended
1096 attributes to be the same as the source ones.
1097
1098 For systems that support extended-attribute namespaces, a copy
1099 being done by a super-user copies all namespaces except sys‐
1100 tem.*. A normal user only copies the user.* namespace. To be
1101 able to backup and restore non-user namespaces as a normal user,
1102 see the --fake-super option.
1103
1104 Note that this option does not copy rsyncs special xattr values
1105 (e.g. those used by --fake-super) unless you repeat the option
1106 (e.g. -XX). This "copy all xattrs" mode cannot be used with
1107 --fake-super.
1108
1109 --chmod
1110 This option tells rsync to apply one or more comma-separated
1111 "chmod" strings to the permission of the files in the transfer.
1112 The resulting value is treated as though it were the permissions
1113 that the sending side supplied for the file, which means that
1114 this option can seem to have no effect on existing files if
1115 --perms is not enabled.
1116
1117 In addition to the normal parsing rules specified in the
1118 chmod(1) manpage, you can specify an item that should only apply
1119 to a directory by prefixing it with a ’D’, or specify an item
1120 that should only apply to a file by prefixing it with a ’F’.
1121 For example, the following will ensure that all directories get
1122 marked set-gid, that no files are other-writable, that both are
1123 user-writable and group-writable, and that both have consistent
1124 executability across all bits:
1125
1126 --chmod=Dg+s,ug+w,Fo-w,+X
1127
1128
1129 It is also legal to specify multiple --chmod options, as each
1130 additional option is just appended to the list of changes to
1131 make.
1132
1133 See the --perms and --executability options for how the result‐
1134 ing permission value can be applied to the files in the trans‐
1135 fer.
1136
1137 -o, --owner
1138 This option causes rsync to set the owner of the destination
1139 file to be the same as the source file, but only if the receiv‐
1140 ing rsync is being run as the super-user (see also the --super
1141 and --fake-super options). Without this option, the owner of
1142 new and/or transferred files are set to the invoking user on the
1143 receiving side.
1144
1145 The preservation of ownership will associate matching names by
1146 default, but may fall back to using the ID number in some cir‐
1147 cumstances (see also the --numeric-ids option for a full discus‐
1148 sion).
1149
1150 -g, --group
1151 This option causes rsync to set the group of the destination
1152 file to be the same as the source file. If the receiving pro‐
1153 gram is not running as the super-user (or if --no-super was
1154 specified), only groups that the invoking user on the receiving
1155 side is a member of will be preserved. Without this option, the
1156 group is set to the default group of the invoking user on the
1157 receiving side.
1158
1159 The preservation of group information will associate matching
1160 names by default, but may fall back to using the ID number in
1161 some circumstances (see also the --numeric-ids option for a full
1162 discussion).
1163
1164 --devices
1165 This option causes rsync to transfer character and block device
1166 files to the remote system to recreate these devices. This
1167 option has no effect if the receiving rsync is not run as the
1168 super-user (see also the --super and --fake-super options).
1169
1170 --specials
1171 This option causes rsync to transfer special files such as named
1172 sockets and fifos.
1173
1174 -D The -D option is equivalent to --devices --specials.
1175
1176 -t, --times
1177 This tells rsync to transfer modification times along with the
1178 files and update them on the remote system. Note that if this
1179 option is not used, the optimization that excludes files that
1180 have not been modified cannot be effective; in other words, a
1181 missing -t or -a will cause the next transfer to behave as if it
1182 used -I, causing all files to be updated (though rsync’s
1183 delta-transfer algorithm will make the update fairly efficient
1184 if the files haven’t actually changed, you’re much better off
1185 using -t).
1186
1187 -O, --omit-dir-times
1188 This tells rsync to omit directories when it is preserving modi‐
1189 fication times (see --times). If NFS is sharing the directories
1190 on the receiving side, it is a good idea to use -O. This option
1191 is inferred if you use --backup without --backup-dir.
1192
1193 --super
1194 This tells the receiving side to attempt super-user activities
1195 even if the receiving rsync wasn’t run by the super-user. These
1196 activities include: preserving users via the --owner option,
1197 preserving all groups (not just the current user’s groups) via
1198 the --groups option, and copying devices via the --devices
1199 option. This is useful for systems that allow such activities
1200 without being the super-user, and also for ensuring that you
1201 will get errors if the receiving side isn’t being run as the
1202 super-user. To turn off super-user activities, the super-user
1203 can use --no-super.
1204
1205 --fake-super
1206 When this option is enabled, rsync simulates super-user activi‐
1207 ties by saving/restoring the privileged attributes via special
1208 extended attributes that are attached to each file (as needed).
1209 This includes the file’s owner and group (if it is not the
1210 default), the file’s device info (device & special files are
1211 created as empty text files), and any permission bits that we
1212 won’t allow to be set on the real file (e.g. the real file gets
1213 u-s,g-s,o-t for safety) or that would limit the owner’s access
1214 (since the real super-user can always access/change a file, the
1215 files we create can always be accessed/changed by the creating
1216 user). This option also handles ACLs (if --acls was specified)
1217 and non-user extended attributes (if --xattrs was specified).
1218
1219 This is a good way to backup data without using a super-user,
1220 and to store ACLs from incompatible systems.
1221
1222 The --fake-super option only affects the side where the option
1223 is used. To affect the remote side of a remote-shell connec‐
1224 tion, specify an rsync path:
1225
1226 rsync -av --rsync-path="rsync --fake-super" /src/ host:/dest/
1227
1228
1229 Since there is only one "side" in a local copy, this option
1230 affects both the sending and receiving of files. You’ll need to
1231 specify a copy using "localhost" if you need to avoid this, pos‐
1232 sibly using the "lsh" shell script (from the support directory)
1233 as a substitute for an actual remote shell (see --rsh).
1234
1235 This option is overridden by both --super and --no-super.
1236
1237 See also the "fake super" setting in the daemon’s rsyncd.conf
1238 file.
1239
1240 -S, --sparse
1241 Try to handle sparse files efficiently so they take up less
1242 space on the destination. Conflicts with --inplace because it’s
1243 not possible to overwrite data in a sparse fashion.
1244
1245 -n, --dry-run
1246 This makes rsync perform a trial run that doesn’t make any
1247 changes (and produces mostly the same output as a real run). It
1248 is most commonly used in combination with the -v, --verbose
1249 and/or -i, --itemize-changes options to see what an rsync com‐
1250 mand is going to do before one actually runs it.
1251
1252 The output of --itemize-changes is supposed to be exactly the
1253 same on a dry run and a subsequent real run (barring intentional
1254 trickery and system call failures); if it isn’t, that’s a bug.
1255 Other output should be mostly unchanged, but may differ in some
1256 areas. Notably, a dry run does not send the actual data for
1257 file transfers, so --progress has no effect, the "bytes sent",
1258 "bytes received", "literal data", and "matched data" statistics
1259 are too small, and the "speedup" value is equivalent to a run
1260 where no file transfers were needed.
1261
1262 -W, --whole-file
1263 With this option rsync’s delta-transfer algorithm is not used
1264 and the whole file is sent as-is instead. The transfer may be
1265 faster if this option is used when the bandwidth between the
1266 source and destination machines is higher than the bandwidth to
1267 disk (especially when the "disk" is actually a networked
1268 filesystem). This is the default when both the source and des‐
1269 tination are specified as local paths, but only if no
1270 batch-writing option is in effect.
1271
1272 -x, --one-file-system
1273 This tells rsync to avoid crossing a filesystem boundary when
1274 recursing. This does not limit the user’s ability to specify
1275 items to copy from multiple filesystems, just rsync’s recursion
1276 through the hierarchy of each directory that the user specified,
1277 and also the analogous recursion on the receiving side during
1278 deletion. Also keep in mind that rsync treats a "bind" mount to
1279 the same device as being on the same filesystem.
1280
1281 If this option is repeated, rsync omits all mount-point directo‐
1282 ries from the copy. Otherwise, it includes an empty directory
1283 at each mount-point it encounters (using the attributes of the
1284 mounted directory because those of the underlying mount-point
1285 directory are inaccessible).
1286
1287 If rsync has been told to collapse symlinks (via --copy-links or
1288 --copy-unsafe-links), a symlink to a directory on another device
1289 is treated like a mount-point. Symlinks to non-directories are
1290 unaffected by this option.
1291
1292 --existing, --ignore-non-existing
1293 This tells rsync to skip creating files (including directories)
1294 that do not exist yet on the destination. If this option is
1295 combined with the --ignore-existing option, no files will be
1296 updated (which can be useful if all you want to do is delete
1297 extraneous files).
1298
1299 This option is a transfer rule, not an exclude, so it doesn’t
1300 affect the data that goes into the file-lists, and thus it
1301 doesn’t affect deletions. It just limits the files that the
1302 receiver requests to be transferred.
1303
1304 --ignore-existing
1305 This tells rsync to skip updating files that already exist on
1306 the destination (this does not ignore existing directories, or
1307 nothing would get done). See also --existing.
1308
1309 This option is a transfer rule, not an exclude, so it doesn’t
1310 affect the data that goes into the file-lists, and thus it
1311 doesn’t affect deletions. It just limits the files that the
1312 receiver requests to be transferred.
1313
1314 This option can be useful for those doing backups using the
1315 --link-dest option when they need to continue a backup run that
1316 got interrupted. Since a --link-dest run is copied into a new
1317 directory hierarchy (when it is used properly), using --ignore
1318 existing will ensure that the already-handled files don’t get
1319 tweaked (which avoids a change in permissions on the hard-linked
1320 files). This does mean that this option is only looking at the
1321 existing files in the destination hierarchy itself.
1322
1323 --remove-source-files
1324 This tells rsync to remove from the sending side the files
1325 (meaning non-directories) that are a part of the transfer and
1326 have been successfully duplicated on the receiving side.
1327
1328 --delete
1329 This tells rsync to delete extraneous files from the receiving
1330 side (ones that aren’t on the sending side), but only for the
1331 directories that are being synchronized. You must have asked
1332 rsync to send the whole directory (e.g. "dir" or "dir/") without
1333 using a wildcard for the directory’s contents (e.g. "dir/*")
1334 since the wildcard is expanded by the shell and rsync thus gets
1335 a request to transfer individual files, not the files’ parent
1336 directory. Files that are excluded from the transfer are also
1337 excluded from being deleted unless you use the --delete-excluded
1338 option or mark the rules as only matching on the sending side
1339 (see the include/exclude modifiers in the FILTER RULES section).
1340
1341 Prior to rsync 2.6.7, this option would have no effect unless
1342 --recursive was enabled. Beginning with 2.6.7, deletions will
1343 also occur when --dirs (-d) is enabled, but only for directories
1344 whose contents are being copied.
1345
1346 This option can be dangerous if used incorrectly! It is a very
1347 good idea to first try a run using the --dry-run option (-n) to
1348 see what files are going to be deleted.
1349
1350 If the sending side detects any I/O errors, then the deletion of
1351 any files at the destination will be automatically disabled.
1352 This is to prevent temporary filesystem failures (such as NFS
1353 errors) on the sending side from causing a massive deletion of
1354 files on the destination. You can override this with the
1355 --ignore-errors option.
1356
1357 The --delete option may be combined with one of the
1358 --delete-WHEN options without conflict, as well as
1359 --delete-excluded. However, if none of the --delete-WHEN
1360 options are specified, rsync will choose the --delete-during
1361 algorithm when talking to rsync 3.0.0 or newer, and the
1362 --delete-before algorithm when talking to an older rsync. See
1363 also --delete-delay and --delete-after.
1364
1365 --delete-before
1366 Request that the file-deletions on the receiving side be done
1367 before the transfer starts. See --delete (which is implied) for
1368 more details on file-deletion.
1369
1370 Deleting before the transfer is helpful if the filesystem is
1371 tight for space and removing extraneous files would help to make
1372 the transfer possible. However, it does introduce a delay
1373 before the start of the transfer, and this delay might cause the
1374 transfer to timeout (if --timeout was specified). It also
1375 forces rsync to use the old, non-incremental recursion algorithm
1376 that requires rsync to scan all the files in the transfer into
1377 memory at once (see --recursive).
1378
1379 --delete-during, --del
1380 Request that the file-deletions on the receiving side be done
1381 incrementally as the transfer happens. The per-directory delete
1382 scan is done right before each directory is checked for updates,
1383 so it behaves like a more efficient --delete-before, including
1384 doing the deletions prior to any per-directory filter files
1385 being updated. This option was first added in rsync version
1386 2.6.4. See --delete (which is implied) for more details on
1387 file-deletion.
1388
1389 --delete-delay
1390 Request that the file-deletions on the receiving side be com‐
1391 puted during the transfer (like --delete-during), and then
1392 removed after the transfer completes. This is useful when com‐
1393 bined with --delay-updates and/or --fuzzy, and is more efficient
1394 than using --delete-after (but can behave differently, since
1395 --delete-after computes the deletions in a separate pass after
1396 all updates are done). If the number of removed files overflows
1397 an internal buffer, a temporary file will be created on the
1398 receiving side to hold the names (it is removed while open, so
1399 you shouldn’t see it during the transfer). If the creation of
1400 the temporary file fails, rsync will try to fall back to using
1401 --delete-after (which it cannot do if --recursive is doing an
1402 incremental scan). See --delete (which is implied) for more
1403 details on file-deletion.
1404
1405 --delete-after
1406 Request that the file-deletions on the receiving side be done
1407 after the transfer has completed. This is useful if you are
1408 sending new per-directory merge files as a part of the transfer
1409 and you want their exclusions to take effect for the delete
1410 phase of the current transfer. It also forces rsync to use the
1411 old, non-incremental recursion algorithm that requires rsync to
1412 scan all the files in the transfer into memory at once (see
1413 --recursive). See --delete (which is implied) for more details
1414 on file-deletion.
1415
1416 --delete-excluded
1417 In addition to deleting the files on the receiving side that are
1418 not on the sending side, this tells rsync to also delete any
1419 files on the receiving side that are excluded (see --exclude).
1420 See the FILTER RULES section for a way to make individual exclu‐
1421 sions behave this way on the receiver, and for a way to protect
1422 files from --delete-excluded. See --delete (which is implied)
1423 for more details on file-deletion.
1424
1425 --ignore-errors
1426 Tells --delete to go ahead and delete files even when there are
1427 I/O errors.
1428
1429 --force
1430 This option tells rsync to delete a non-empty directory when it
1431 is to be replaced by a non-directory. This is only relevant if
1432 deletions are not active (see --delete for details).
1433
1434 Note for older rsync versions: --force used to still be required
1435 when using --delete-after, and it used to be non-functional
1436 unless the --recursive option was also enabled.
1437
1438 --max-delete=NUM
1439 This tells rsync not to delete more than NUM files or directo‐
1440 ries. If that limit is exceeded, a warning is output and rsync
1441 exits with an error code of 25 (new for 3.0.0).
1442
1443 Also new for version 3.0.0, you may specify --max-delete=0 to be
1444 warned about any extraneous files in the destination without
1445 removing any of them. Older clients interpreted this as "unlim‐
1446 ited", so if you don’t know what version the client is, you can
1447 use the less obvious --max-delete=-1 as a backward-compatible
1448 way to specify that no deletions be allowed (though older ver‐
1449 sions didn’t warn when the limit was exceeded).
1450
1451 --max-size=SIZE
1452 This tells rsync to avoid transferring any file that is larger
1453 than the specified SIZE. The SIZE value can be suffixed with a
1454 string to indicate a size multiplier, and may be a fractional
1455 value (e.g. "--max-size=1.5m").
1456
1457 This option is a transfer rule, not an exclude, so it doesn’t
1458 affect the data that goes into the file-lists, and thus it
1459 doesn’t affect deletions. It just limits the files that the
1460 receiver requests to be transferred.
1461
1462 The suffixes are as follows: "K" (or "KiB") is a kibibyte
1463 (1024), "M" (or "MiB") is a mebibyte (1024*1024), and "G" (or
1464 "GiB") is a gibibyte (1024*1024*1024). If you want the multi‐
1465 plier to be 1000 instead of 1024, use "KB", "MB", or "GB".
1466 (Note: lower-case is also accepted for all values.) Finally, if
1467 the suffix ends in either "+1" or "-1", the value will be offset
1468 by one byte in the indicated direction.
1469
1470 Examples: --max-size=1.5mb-1 is 1499999 bytes, and
1471 --max-size=2g+1 is 2147483649 bytes.
1472
1473 --min-size=SIZE
1474 This tells rsync to avoid transferring any file that is smaller
1475 than the specified SIZE, which can help in not transferring
1476 small, junk files. See the --max-size option for a description
1477 of SIZE and other information.
1478
1479 -B, --block-size=BLOCKSIZE
1480 This forces the block size used in rsync’s delta-transfer algo‐
1481 rithm to a fixed value. It is normally selected based on the
1482 size of each file being updated. See the technical report for
1483 details.
1484
1485 -e, --rsh=COMMAND
1486 This option allows you to choose an alternative remote shell
1487 program to use for communication between the local and remote
1488 copies of rsync. Typically, rsync is configured to use ssh by
1489 default, but you may prefer to use rsh on a local network.
1490
1491 If this option is used with [user@]host::module/path, then the
1492 remote shell COMMAND will be used to run an rsync daemon on the
1493 remote host, and all data will be transmitted through that
1494 remote shell connection, rather than through a direct socket
1495 connection to a running rsync daemon on the remote host. See
1496 the section "USING RSYNC-DAEMON FEATURES VIA A REMOTE-SHELL CON‐
1497 NECTION" above.
1498
1499 Command-line arguments are permitted in COMMAND provided that
1500 COMMAND is presented to rsync as a single argument. You must
1501 use spaces (not tabs or other whitespace) to separate the com‐
1502 mand and args from each other, and you can use single- and/or
1503 double-quotes to preserve spaces in an argument (but not back‐
1504 slashes). Note that doubling a single-quote inside a sin‐
1505 gle-quoted string gives you a single-quote; likewise for dou‐
1506 ble-quotes (though you need to pay attention to which quotes
1507 your shell is parsing and which quotes rsync is parsing). Some
1508 examples:
1509
1510 -e 'ssh -p 2234'
1511 -e 'ssh -o "ProxyCommand nohup ssh firewall nc -w1 %h %p"'
1512
1513
1514 (Note that ssh users can alternately customize site-specific
1515 connect options in their .ssh/config file.)
1516
1517 You can also choose the remote shell program using the RSYNC_RSH
1518 environment variable, which accepts the same range of values as
1519 -e.
1520
1521 See also the --blocking-io option which is affected by this
1522 option.
1523
1524 --rsync-path=PROGRAM
1525 Use this to specify what program is to be run on the remote
1526 machine to start-up rsync. Often used when rsync is not in the
1527 default remote-shell’s path (e.g.
1528 --rsync-path=/usr/local/bin/rsync). Note that PROGRAM is run
1529 with the help of a shell, so it can be any program, script, or
1530 command sequence you’d care to run, so long as it does not cor‐
1531 rupt the standard-in & standard-out that rsync is using to com‐
1532 municate.
1533
1534 One tricky example is to set a different default directory on
1535 the remote machine for use with the --relative option. For
1536 instance:
1537
1538 rsync -avR --rsync-path="cd /a/b && rsync" host:c/d /e/
1539
1540
1541 -C, --cvs-exclude
1542 This is a useful shorthand for excluding a broad range of files
1543 that you often don’t want to transfer between systems. It uses a
1544 similar algorithm to CVS to determine if a file should be
1545 ignored.
1546
1547 The exclude list is initialized to exclude the following items
1548 (these initial items are marked as perishable -- see the FILTER
1549 RULES section):
1550
1551 RCS SCCS CVS CVS.adm RCSLOG cvslog.* tags TAGS
1552 .make.state .nse_depinfo *~ #* .#* ,* _$* *$ *.old *.bak
1553 *.BAK *.orig *.rej .del-* *.a *.olb *.o *.obj *.so *.exe
1554 *.Z *.elc *.ln core .svn/ .git/ .hg/ .bzr/
1555
1556
1557 then, files listed in a $HOME/.cvsignore are added to the list
1558 and any files listed in the CVSIGNORE environment variable (all
1559 cvsignore names are delimited by whitespace).
1560
1561 Finally, any file is ignored if it is in the same directory as a
1562 .cvsignore file and matches one of the patterns listed therein.
1563 Unlike rsync’s filter/exclude files, these patterns are split on
1564 whitespace. See the cvs(1) manual for more information.
1565
1566 If you’re combining -C with your own --filter rules, you should
1567 note that these CVS excludes are appended at the end of your own
1568 rules, regardless of where the -C was placed on the com‐
1569 mand-line. This makes them a lower priority than any rules you
1570 specified explicitly. If you want to control where these CVS
1571 excludes get inserted into your filter rules, you should omit
1572 the -C as a command-line option and use a combination of --fil‐
1573 ter=:C and --filter=-C (either on your command-line or by
1574 putting the ":C" and "-C" rules into a filter file with your
1575 other rules). The first option turns on the per-directory scan‐
1576 ning for the .cvsignore file. The second option does a one-time
1577 import of the CVS excludes mentioned above.
1578
1579 -f, --filter=RULE
1580 This option allows you to add rules to selectively exclude cer‐
1581 tain files from the list of files to be transferred. This is
1582 most useful in combination with a recursive transfer.
1583
1584 You may use as many --filter options on the command line as you
1585 like to build up the list of files to exclude. If the filter
1586 contains whitespace, be sure to quote it so that the shell gives
1587 the rule to rsync as a single argument. The text below also
1588 mentions that you can use an underscore to replace the space
1589 that separates a rule from its arg.
1590
1591 See the FILTER RULES section for detailed information on this
1592 option.
1593
1594 -F The -F option is a shorthand for adding two --filter rules to
1595 your command. The first time it is used is a shorthand for this
1596 rule:
1597
1598 --filter='dir-merge /.rsync-filter'
1599
1600
1601 This tells rsync to look for per-directory .rsync-filter files
1602 that have been sprinkled through the hierarchy and use their
1603 rules to filter the files in the transfer. If -F is repeated,
1604 it is a shorthand for this rule:
1605
1606 --filter='exclude .rsync-filter'
1607
1608
1609 This filters out the .rsync-filter files themselves from the
1610 transfer.
1611
1612 See the FILTER RULES section for detailed information on how
1613 these options work.
1614
1615 --exclude=PATTERN
1616 This option is a simplified form of the --filter option that
1617 defaults to an exclude rule and does not allow the full
1618 rule-parsing syntax of normal filter rules.
1619
1620 See the FILTER RULES section for detailed information on this
1621 option.
1622
1623 --exclude-from=FILE
1624 This option is related to the --exclude option, but it specifies
1625 a FILE that contains exclude patterns (one per line). Blank
1626 lines in the file and lines starting with ’;’ or ’#’ are
1627 ignored. If FILE is -, the list will be read from standard
1628 input.
1629
1630 --include=PATTERN
1631 This option is a simplified form of the --filter option that
1632 defaults to an include rule and does not allow the full
1633 rule-parsing syntax of normal filter rules.
1634
1635 See the FILTER RULES section for detailed information on this
1636 option.
1637
1638 --include-from=FILE
1639 This option is related to the --include option, but it specifies
1640 a FILE that contains include patterns (one per line). Blank
1641 lines in the file and lines starting with ’;’ or ’#’ are
1642 ignored. If FILE is -, the list will be read from standard
1643 input.
1644
1645 --files-from=FILE
1646 Using this option allows you to specify the exact list of files
1647 to transfer (as read from the specified FILE or - for standard
1648 input). It also tweaks the default behavior of rsync to make
1649 transferring just the specified files and directories easier:
1650
1651 o The --relative (-R) option is implied, which preserves
1652 the path information that is specified for each item in
1653 the file (use --no-relative or --no-R if you want to turn
1654 that off).
1655
1656 o The --dirs (-d) option is implied, which will create
1657 directories specified in the list on the destination
1658 rather than noisily skipping them (use --no-dirs or
1659 --no-d if you want to turn that off).
1660
1661 o The --archive (-a) option’s behavior does not imply
1662 --recursive (-r), so specify it explicitly, if you want
1663 it.
1664
1665 o These side-effects change the default state of rsync, so
1666 the position of the --files-from option on the com‐
1667 mand-line has no bearing on how other options are parsed
1668 (e.g. -a works the same before or after --files-from, as
1669 does --no-R and all other options).
1670
1671
1672 The filenames that are read from the FILE are all relative to
1673 the source dir -- any leading slashes are removed and no ".."
1674 references are allowed to go higher than the source dir. For
1675 example, take this command:
1676
1677 rsync -a --files-from=/tmp/foo /usr remote:/backup
1678
1679
1680 If /tmp/foo contains the string "bin" (or even "/bin"), the
1681 /usr/bin directory will be created as /backup/bin on the remote
1682 host. If it contains "bin/" (note the trailing slash), the
1683 immediate contents of the directory would also be sent (without
1684 needing to be explicitly mentioned in the file -- this began in
1685 version 2.6.4). In both cases, if the -r option was enabled,
1686 that dir’s entire hierarchy would also be transferred (keep in
1687 mind that -r needs to be specified explicitly with --files-from,
1688 since it is not implied by -a). Also note that the effect of
1689 the (enabled by default) --relative option is to duplicate only
1690 the path info that is read from the file -- it does not force
1691 the duplication of the source-spec path (/usr in this case).
1692
1693 In addition, the --files-from file can be read from the remote
1694 host instead of the local host if you specify a "host:" in front
1695 of the file (the host must match one end of the transfer). As a
1696 short-cut, you can specify just a prefix of ":" to mean "use the
1697 remote end of the transfer". For example:
1698
1699 rsync -a --files-from=:/path/file-list src:/ /tmp/copy
1700
1701
1702 This would copy all the files specified in the /path/file-list
1703 file that was located on the remote "src" host.
1704
1705 If the --iconv and --protect-args options are specified and the
1706 --files-from filenames are being sent from one host to another,
1707 the filenames will be translated from the sending host’s charset
1708 to the receiving host’s charset.
1709
1710 NOTE: sorting the list of files in the --files-from input helps
1711 rsync to be more efficient, as it will avoid re-visiting the
1712 path elements that are shared between adjacent entries. If the
1713 input is not sorted, some path elements (implied directories)
1714 may end up being scanned multiple times, and rsync will eventu‐
1715 ally unduplicate them after they get turned into file-list ele‐
1716 ments.
1717
1718 -0, --from0
1719 This tells rsync that the rules/filenames it reads from a file
1720 are terminated by a null (’\0’) character, not a NL, CR, or
1721 CR+LF. This affects --exclude-from, --include-from,
1722 --files-from, and any merged files specified in a --filter rule.
1723 It does not affect --cvs-exclude (since all names read from a
1724 .cvsignore file are split on whitespace).
1725
1726 -s, --protect-args
1727 This option sends all filenames and most options to the remote
1728 rsync without allowing the remote shell to interpret them. This
1729 means that spaces are not split in names, and any non-wildcard
1730 special characters are not translated (such as ~, $, ;, &,
1731 etc.). Wildcards are expanded on the remote host by rsync
1732 (instead of the shell doing it).
1733
1734 If you use this option with --iconv, the args related to the
1735 remote side will also be translated from the local to the remote
1736 character-set. The translation happens before wild-cards are
1737 expanded. See also the --files-from option.
1738
1739 -T, --temp-dir=DIR
1740 This option instructs rsync to use DIR as a scratch directory
1741 when creating temporary copies of the files transferred on the
1742 receiving side. The default behavior is to create each tempo‐
1743 rary file in the same directory as the associated destination
1744 file.
1745
1746 This option is most often used when the receiving disk partition
1747 does not have enough free space to hold a copy of the largest
1748 file in the transfer. In this case (i.e. when the scratch
1749 directory is on a different disk partition), rsync will not be
1750 able to rename each received temporary file over the top of the
1751 associated destination file, but instead must copy it into
1752 place. Rsync does this by copying the file over the top of the
1753 destination file, which means that the destination file will
1754 contain truncated data during this copy. If this were not done
1755 this way (even if the destination file were first removed, the
1756 data locally copied to a temporary file in the destination
1757 directory, and then renamed into place) it would be possible for
1758 the old file to continue taking up disk space (if someone had it
1759 open), and thus there might not be enough room to fit the new
1760 version on the disk at the same time.
1761
1762 If you are using this option for reasons other than a shortage
1763 of disk space, you may wish to combine it with the
1764 --delay-updates option, which will ensure that all copied files
1765 get put into subdirectories in the destination hierarchy, await‐
1766 ing the end of the transfer. If you don’t have enough room to
1767 duplicate all the arriving files on the destination partition,
1768 another way to tell rsync that you aren’t overly concerned about
1769 disk space is to use the --partial-dir option with a relative
1770 path; because this tells rsync that it is OK to stash off a copy
1771 of a single file in a subdir in the destination hierarchy, rsync
1772 will use the partial-dir as a staging area to bring over the
1773 copied file, and then rename it into place from there. (Specify‐
1774 ing a --partial-dir with an absolute path does not have this
1775 side-effect.)
1776
1777 -y, --fuzzy
1778 This option tells rsync that it should look for a basis file for
1779 any destination file that is missing. The current algorithm
1780 looks in the same directory as the destination file for either a
1781 file that has an identical size and modified-time, or a simi‐
1782 larly-named file. If found, rsync uses the fuzzy basis file to
1783 try to speed up the transfer.
1784
1785 Note that the use of the --delete option might get rid of any
1786 potential fuzzy-match files, so either use --delete-after or
1787 specify some filename exclusions if you need to prevent this.
1788
1789 --compare-dest=DIR
1790 This option instructs rsync to use DIR on the destination
1791 machine as an additional hierarchy to compare destination files
1792 against doing transfers (if the files are missing in the desti‐
1793 nation directory). If a file is found in DIR that is identical
1794 to the sender’s file, the file will NOT be transferred to the
1795 destination directory. This is useful for creating a sparse
1796 backup of just files that have changed from an earlier backup.
1797
1798 Beginning in version 2.6.4, multiple --compare-dest directories
1799 may be provided, which will cause rsync to search the list in
1800 the order specified for an exact match. If a match is found
1801 that differs only in attributes, a local copy is made and the
1802 attributes updated. If a match is not found, a basis file from
1803 one of the DIRs will be selected to try to speed up the trans‐
1804 fer.
1805
1806 If DIR is a relative path, it is relative to the destination
1807 directory. See also --copy-dest and --link-dest.
1808
1809 --copy-dest=DIR
1810 This option behaves like --compare-dest, but rsync will also
1811 copy unchanged files found in DIR to the destination directory
1812 using a local copy. This is useful for doing transfers to a new
1813 destination while leaving existing files intact, and then doing
1814 a flash-cutover when all files have been successfully trans‐
1815 ferred.
1816
1817 Multiple --copy-dest directories may be provided, which will
1818 cause rsync to search the list in the order specified for an
1819 unchanged file. If a match is not found, a basis file from one
1820 of the DIRs will be selected to try to speed up the transfer.
1821
1822 If DIR is a relative path, it is relative to the destination
1823 directory. See also --compare-dest and --link-dest.
1824
1825 --link-dest=DIR
1826 This option behaves like --copy-dest, but unchanged files are
1827 hard linked from DIR to the destination directory. The files
1828 must be identical in all preserved attributes (e.g. permissions,
1829 possibly ownership) in order for the files to be linked
1830 together. An example:
1831
1832 rsync -av --link-dest=$PWD/prior_dir host:src_dir/ new_dir/
1833
1834
1835 If file’s aren’t linking, double-check their attributes. Also
1836 check if some attributes are getting forced outside of rsync’s
1837 control, such a mount option that squishes root to a single
1838 user, or mounts a removable drive with generic ownership (such
1839 as OS X’s "Ignore ownership on this volume" option).
1840
1841 Beginning in version 2.6.4, multiple --link-dest directories may
1842 be provided, which will cause rsync to search the list in the
1843 order specified for an exact match. If a match is found that
1844 differs only in attributes, a local copy is made and the
1845 attributes updated. If a match is not found, a basis file from
1846 one of the DIRs will be selected to try to speed up the trans‐
1847 fer.
1848
1849 This option works best when copying into an empty destination
1850 hierarchy, as rsync treats existing files as definitive (so it
1851 never looks in the link-dest dirs when a destination file
1852 already exists), and as malleable (so it might change the
1853 attributes of a destination file, which affects all the
1854 hard-linked versions).
1855
1856 Note that if you combine this option with --ignore-times, rsync
1857 will not link any files together because it only links identical
1858 files together as a substitute for transferring the file, never
1859 as an additional check after the file is updated.
1860
1861 If DIR is a relative path, it is relative to the destination
1862 directory. See also --compare-dest and --copy-dest.
1863
1864 Note that rsync versions prior to 2.6.1 had a bug that could
1865 prevent --link-dest from working properly for a non-super-user
1866 when -o was specified (or implied by -a). You can work-around
1867 this bug by avoiding the -o option when sending to an old rsync.
1868
1869 -z, --compress
1870 With this option, rsync compresses the file data as it is sent
1871 to the destination machine, which reduces the amount of data
1872 being transmitted -- something that is useful over a slow con‐
1873 nection.
1874
1875 Note that this option typically achieves better compression
1876 ratios than can be achieved by using a compressing remote shell
1877 or a compressing transport because it takes advantage of the
1878 implicit information in the matching data blocks that are not
1879 explicitly sent over the connection.
1880
1881 See the --skip-compress option for the default list of file suf‐
1882 fixes that will not be compressed.
1883
1884 --compress-level=NUM
1885 Explicitly set the compression level to use (see --compress)
1886 instead of letting it default. If NUM is non-zero, the --com‐
1887 press option is implied.
1888
1889 --skip-compress=LIST
1890 Override the list of file suffixes that will not be compressed.
1891 The LIST should be one or more file suffixes (without the dot)
1892 separated by slashes (/).
1893
1894 You may specify an empty string to indicate that no file should
1895 be skipped.
1896
1897 Simple character-class matching is supported: each must consist
1898 of a list of letters inside the square brackets (e.g. no special
1899 classes, such as "[:alpha:]", are supported, and ’-’ has no spe‐
1900 cial meaning).
1901
1902 The characters asterisk (*) and question-mark (?) have no spe‐
1903 cial meaning.
1904
1905 Here’s an example that specifies 6 suffixes to skip (since 1 of
1906 the 5 rules matches 2 suffixes):
1907
1908 --skip-compress=gz/jpg/mp[34]/7z/bz2
1909
1910
1911 The default list of suffixes that will not be compressed is this
1912 (in this version of rsync):
1913
1914 7z avi bz2 deb gz iso jpeg jpg mov mp3 mp4 ogg rpm tbz tgz z zip
1915
1916 This list will be replaced by your --skip-compress list in all
1917 but one situation: a copy from a daemon rsync will add your
1918 skipped suffixes to its list of non-compressing files (and its
1919 list may be configured to a different default).
1920
1921 --numeric-ids
1922 With this option rsync will transfer numeric group and user IDs
1923 rather than using user and group names and mapping them at both
1924 ends.
1925
1926 By default rsync will use the username and groupname to deter‐
1927 mine what ownership to give files. The special uid 0 and the
1928 special group 0 are never mapped via user/group names even if
1929 the --numeric-ids option is not specified.
1930
1931 If a user or group has no name on the source system or it has no
1932 match on the destination system, then the numeric ID from the
1933 source system is used instead. See also the comments on the
1934 "use chroot" setting in the rsyncd.conf manpage for information
1935 on how the chroot setting affects rsync’s ability to look up the
1936 names of the users and groups and what you can do about it.
1937
1938 --timeout=TIMEOUT
1939 This option allows you to set a maximum I/O timeout in seconds.
1940 If no data is transferred for the specified time then rsync will
1941 exit. The default is 0, which means no timeout.
1942
1943 --contimeout
1944 This option allows you to set the amount of time that rsync will
1945 wait for its connection to an rsync daemon to succeed. If the
1946 timeout is reached, rsync exits with an error.
1947
1948 --address
1949 By default rsync will bind to the wildcard address when connect‐
1950 ing to an rsync daemon. The --address option allows you to
1951 specify a specific IP address (or hostname) to bind to. See
1952 also this option in the --daemon mode section.
1953
1954 --port=PORT
1955 This specifies an alternate TCP port number to use rather than
1956 the default of 873. This is only needed if you are using the
1957 double-colon (::) syntax to connect with an rsync daemon (since
1958 the URL syntax has a way to specify the port as a part of the
1959 URL). See also this option in the --daemon mode section.
1960
1961 --sockopts
1962 This option can provide endless fun for people who like to tune
1963 their systems to the utmost degree. You can set all sorts of
1964 socket options which may make transfers faster (or slower!).
1965 Read the man page for the setsockopt() system call for details
1966 on some of the options you may be able to set. By default no
1967 special socket options are set. This only affects direct socket
1968 connections to a remote rsync daemon. This option also exists
1969 in the --daemon mode section.
1970
1971 --blocking-io
1972 This tells rsync to use blocking I/O when launching a remote
1973 shell transport. If the remote shell is either rsh or remsh,
1974 rsync defaults to using blocking I/O, otherwise it defaults to
1975 using non-blocking I/O. (Note that ssh prefers non-blocking
1976 I/O.)
1977
1978 -i, --itemize-changes
1979 Requests a simple itemized list of the changes that are being
1980 made to each file, including attribute changes. This is exactly
1981 the same as specifying --out-format='%i %n%L'. If you repeat
1982 the option, unchanged files will also be output, but only if the
1983 receiving rsync is at least version 2.6.7 (you can use -vv with
1984 older versions of rsync, but that also turns on the output of
1985 other verbose messages).
1986
1987 The "%i" escape has a cryptic output that is 11 letters long.
1988 The general format is like the string YXcstpoguax, where Y is
1989 replaced by the type of update being done, X is replaced by the
1990 file-type, and the other letters represent attributes that may
1991 be output if they are being modified.
1992
1993 The update types that replace the Y are as follows:
1994
1995 o A < means that a file is being transferred to the remote
1996 host (sent).
1997
1998 o A > means that a file is being transferred to the local
1999 host (received).
2000
2001 o A c means that a local change/creation is occurring for
2002 the item (such as the creation of a directory or the
2003 changing of a symlink, etc.).
2004
2005 o A h means that the item is a hard link to another item
2006 (requires --hard-links).
2007
2008 o A . means that the item is not being updated (though it
2009 might have attributes that are being modified).
2010
2011 o A * means that the rest of the itemized-output area con‐
2012 tains a message (e.g. "deleting").
2013
2014
2015 The file-types that replace the X are: f for a file, a d for a
2016 directory, an L for a symlink, a D for a device, and a S for a
2017 special file (e.g. named sockets and fifos).
2018
2019 The other letters in the string above are the actual letters
2020 that will be output if the associated attribute for the item is
2021 being updated or a "." for no change. Three exceptions to this
2022 are: (1) a newly created item replaces each letter with a "+",
2023 (2) an identical item replaces the dots with spaces, and (3) an
2024 unknown attribute replaces each letter with a "?" (this can hap‐
2025 pen when talking to an older rsync).
2026
2027 The attribute that is associated with each letter is as follows:
2028
2029 o A c means either that a regular file has a different
2030 checksum (requires --checksum) or that a symlink, device,
2031 or special file has a changed value. Note that if you
2032 are sending files to an rsync prior to 3.0.1, this change
2033 flag will be present only for checksum-differing regular
2034 files.
2035
2036 o A s means the size of a regular file is different and
2037 will be updated by the file transfer.
2038
2039 o A t means the modification time is different and is being
2040 updated to the sender’s value (requires --times). An
2041 alternate value of T means that the modification time
2042 will be set to the transfer time, which happens when a
2043 file/symlink/device is updated without --times and when a
2044 symlink is changed and the receiver can’t set its time.
2045 (Note: when using an rsync 3.0.0 client, you might see
2046 the s flag combined with t instead of the proper T flag
2047 for this time-setting failure.)
2048
2049 o A p means the permissions are different and are being
2050 updated to the sender’s value (requires --perms).
2051
2052 o An o means the owner is different and is being updated to
2053 the sender’s value (requires --owner and super-user priv‐
2054 ileges).
2055
2056 o A g means the group is different and is being updated to
2057 the sender’s value (requires --group and the authority to
2058 set the group).
2059
2060 o The u slot is reserved for future use.
2061
2062 o The a means that the ACL information changed.
2063
2064 o The x means that the extended attribute information
2065 changed.
2066
2067
2068 One other output is possible: when deleting files, the "%i"
2069 will output the string "*deleting" for each item that is being
2070 removed (assuming that you are talking to a recent enough rsync
2071 that it logs deletions instead of outputting them as a verbose
2072 message).
2073
2074 --out-format=FORMAT
2075 This allows you to specify exactly what the rsync client outputs
2076 to the user on a per-update basis. The format is a text string
2077 containing embedded single-character escape sequences prefixed
2078 with a percent (%) character. A default format of "%n%L" is
2079 assumed if -v is specified (which reports the name of the file
2080 and, if the item is a link, where it points). For a full list
2081 of the possible escape characters, see the "log format" setting
2082 in the rsyncd.conf manpage.
2083
2084 Specifying the --out-format option will mention each file, dir,
2085 etc. that gets updated in a significant way (a transferred file,
2086 a recreated symlink/device, or a touched directory). In addi‐
2087 tion, if the itemize-changes escape (%i) is included in the
2088 string (e.g. if the --itemize-changes option was used), the log‐
2089 ging of names increases to mention any item that is changed in
2090 any way (as long as the receiving side is at least 2.6.4). See
2091 the --itemize-changes option for a description of the output of
2092 "%i".
2093
2094 Rsync will output the out-format string prior to a file’s trans‐
2095 fer unless one of the transfer-statistic escapes is requested,
2096 in which case the logging is done at the end of the file’s
2097 transfer. When this late logging is in effect and --progress is
2098 also specified, rsync will also output the name of the file
2099 being transferred prior to its progress information (followed,
2100 of course, by the out-format output).
2101
2102 --log-file=FILE
2103 This option causes rsync to log what it is doing to a file.
2104 This is similar to the logging that a daemon does, but can be
2105 requested for the client side and/or the server side of a
2106 non-daemon transfer. If specified as a client option, transfer
2107 logging will be enabled with a default format of "%i %n%L". See
2108 the --log-file-format option if you wish to override this.
2109
2110 Here’s a example command that requests the remote side to log
2111 what is happening:
2112
2113 rsync -av --rsync-path="rsync --log-file=/tmp/rlog" src/ dest/
2114
2115
2116 This is very useful if you need to debug why a connection is
2117 closing unexpectedly.
2118
2119 --log-file-format=FORMAT
2120 This allows you to specify exactly what per-update logging is
2121 put into the file specified by the --log-file option (which must
2122 also be specified for this option to have any effect). If you
2123 specify an empty string, updated files will not be mentioned in
2124 the log file. For a list of the possible escape characters, see
2125 the "log format" setting in the rsyncd.conf manpage.
2126
2127 The default FORMAT used if --log-file is specified and this
2128 option is not is ’%i %n%L’.
2129
2130 --stats
2131 This tells rsync to print a verbose set of statistics on the
2132 file transfer, allowing you to tell how effective rsync’s
2133 delta-transfer algorithm is for your data.
2134
2135 The current statistics are as follows:
2136
2137 o Number of files is the count of all "files" (in the
2138 generic sense), which includes directories, symlinks,
2139 etc.
2140
2141 o Number of files transferred is the count of normal files
2142 that were updated via rsync’s delta-transfer algorithm,
2143 which does not include created dirs, symlinks, etc.
2144
2145 o Total file size is the total sum of all file sizes in the
2146 transfer. This does not count any size for directories
2147 or special files, but does include the size of symlinks.
2148
2149 o Total transferred file size is the total sum of all files
2150 sizes for just the transferred files.
2151
2152 o Literal data is how much unmatched file-update data we
2153 had to send to the receiver for it to recreate the
2154 updated files.
2155
2156 o Matched data is how much data the receiver got locally
2157 when recreating the updated files.
2158
2159 o File list size is how big the file-list data was when the
2160 sender sent it to the receiver. This is smaller than the
2161 in-memory size for the file list due to some compressing
2162 of duplicated data when rsync sends the list.
2163
2164 o File list generation time is the number of seconds that
2165 the sender spent creating the file list. This requires a
2166 modern rsync on the sending side for this to be present.
2167
2168 o File list transfer time is the number of seconds that the
2169 sender spent sending the file list to the receiver.
2170
2171 o Total bytes sent is the count of all the bytes that rsync
2172 sent from the client side to the server side.
2173
2174 o Total bytes received is the count of all non-message
2175 bytes that rsync received by the client side from the
2176 server side. "Non-message" bytes means that we don’t
2177 count the bytes for a verbose message that the server
2178 sent to us, which makes the stats more consistent.
2179
2180
2181 -8, --8-bit-output
2182 This tells rsync to leave all high-bit characters unescaped in
2183 the output instead of trying to test them to see if they’re
2184 valid in the current locale and escaping the invalid ones. All
2185 control characters (but never tabs) are always escaped, regard‐
2186 less of this option’s setting.
2187
2188 The escape idiom that started in 2.6.7 is to output a literal
2189 backslash (\) and a hash (#), followed by exactly 3 octal dig‐
2190 its. For example, a newline would output as "\#012". A literal
2191 backslash that is in a filename is not escaped unless it is fol‐
2192 lowed by a hash and 3 digits (0-9).
2193
2194 -h, --human-readable
2195 Output numbers in a more human-readable format. This makes big
2196 numbers output using larger units, with a K, M, or G suffix. If
2197 this option was specified once, these units are K (1000), M
2198 (1000*1000), and G (1000*1000*1000); if the option is repeated,
2199 the units are powers of 1024 instead of 1000.
2200
2201 --partial
2202 By default, rsync will delete any partially transferred file if
2203 the transfer is interrupted. In some circumstances it is more
2204 desirable to keep partially transferred files. Using the --par‐
2205 tial option tells rsync to keep the partial file which should
2206 make a subsequent transfer of the rest of the file much faster.
2207
2208 --partial-dir=DIR
2209 A better way to keep partial files than the --partial option is
2210 to specify a DIR that will be used to hold the partial data
2211 (instead of writing it out to the destination file). On the
2212 next transfer, rsync will use a file found in this dir as data
2213 to speed up the resumption of the transfer and then delete it
2214 after it has served its purpose.
2215
2216 Note that if --whole-file is specified (or implied), any par‐
2217 tial-dir file that is found for a file that is being updated
2218 will simply be removed (since rsync is sending files without
2219 using rsync’s delta-transfer algorithm).
2220
2221 Rsync will create the DIR if it is missing (just the last dir --
2222 not the whole path). This makes it easy to use a relative path
2223 (such as "--partial-dir=.rsync-partial") to have rsync create
2224 the partial-directory in the destination file’s directory when
2225 needed, and then remove it again when the partial file is
2226 deleted.
2227
2228 If the partial-dir value is not an absolute path, rsync will add
2229 an exclude rule at the end of all your existing excludes. This
2230 will prevent the sending of any partial-dir files that may exist
2231 on the sending side, and will also prevent the untimely deletion
2232 of partial-dir items on the receiving side. An example: the
2233 above --partial-dir option would add the equivalent of "-f '-p
2234 .rsync-partial/'" at the end of any other filter rules.
2235
2236 If you are supplying your own exclude rules, you may need to add
2237 your own exclude/hide/protect rule for the partial-dir because
2238 (1) the auto-added rule may be ineffective at the end of your
2239 other rules, or (2) you may wish to override rsync’s exclude
2240 choice. For instance, if you want to make rsync clean-up any
2241 left-over partial-dirs that may be lying around, you should
2242 specify --delete-after and add a "risk" filter rule, e.g. -f 'R
2243 .rsync-partial/'. (Avoid using --delete-before or --delete-dur‐
2244 ing unless you don’t need rsync to use any of the left-over par‐
2245 tial-dir data during the current run.)
2246
2247 IMPORTANT: the --partial-dir should not be writable by other
2248 users or it is a security risk. E.g. AVOID "/tmp".
2249
2250 You can also set the partial-dir value the RSYNC_PARTIAL_DIR
2251 environment variable. Setting this in the environment does not
2252 force --partial to be enabled, but rather it affects where par‐
2253 tial files go when --partial is specified. For instance,
2254 instead of using --partial-dir=.rsync-tmp along with --progress,
2255 you could set RSYNC_PARTIAL_DIR=.rsync-tmp in your environment
2256 and then just use the -P option to turn on the use of the
2257 .rsync-tmp dir for partial transfers. The only times that the
2258 --partial option does not look for this environment value are
2259 (1) when --inplace was specified (since --inplace conflicts with
2260 --partial-dir), and (2) when --delay-updates was specified (see
2261 below).
2262
2263 For the purposes of the daemon-config’s "refuse options" set‐
2264 ting, --partial-dir does not imply --partial. This is so that a
2265 refusal of the --partial option can be used to disallow the
2266 overwriting of destination files with a partial transfer, while
2267 still allowing the safer idiom provided by --partial-dir.
2268
2269 --delay-updates
2270 This option puts the temporary file from each updated file into
2271 a holding directory until the end of the transfer, at which time
2272 all the files are renamed into place in rapid succession. This
2273 attempts to make the updating of the files a little more atomic.
2274 By default the files are placed into a directory named ".~tmp~"
2275 in each file’s destination directory, but if you’ve specified
2276 the --partial-dir option, that directory will be used instead.
2277 See the comments in the --partial-dir section for a discussion
2278 of how this ".~tmp~" dir will be excluded from the transfer, and
2279 what you can do if you want rsync to cleanup old ".~tmp~" dirs
2280 that might be lying around. Conflicts with --inplace and
2281 --append.
2282
2283 This option uses more memory on the receiving side (one bit per
2284 file transferred) and also requires enough free disk space on
2285 the receiving side to hold an additional copy of all the updated
2286 files. Note also that you should not use an absolute path to
2287 --partial-dir [22munless (1) there is no chance of any of the files
2288 in the transfer having the same name (since all the updated
2289 files will be put into a single directory if the path is abso‐
2290 lute) and (2) there are no mount points in the hierarchy (since
2291 the delayed updates will fail if they can’t be renamed into
2292 place).
2293
2294 See also the "atomic-rsync" perl script in the "support" subdir
2295 for an update algorithm that is even more atomic (it uses
2296 --link-dest and a parallel hierarchy of files).
2297
2298 -m, --prune-empty-dirs
2299 This option tells the receiving rsync to get rid of empty direc‐
2300 tories from the file-list, including nested directories that
2301 have no non-directory children. This is useful for avoiding the
2302 creation of a bunch of useless directories when the sending
2303 rsync is recursively scanning a hierarchy of files using
2304 include/exclude/filter rules.
2305
2306 Note that the use of transfer rules, such as the --min-size
2307 option, does not affect what goes into the file list, and thus
2308 does not leave directories empty, even if none of the files in a
2309 directory match the transfer rule.
2310
2311 Because the file-list is actually being pruned, this option also
2312 affects what directories get deleted when a delete is active.
2313 However, keep in mind that excluded files and directories can
2314 prevent existing items from being deleted due to an exclude both
2315 hiding source files and protecting destination files. See the
2316 perishable filter-rule option for how to avoid this.
2317
2318 You can prevent the pruning of certain empty directories from
2319 the file-list by using a global "protect" filter. For instance,
2320 this option would ensure that the directory "emptydir" was kept
2321 in the file-list:
2322
2323 --filter ’protect emptydir/’
2324
2325
2326 Here’s an example that copies all .pdf files in a hierarchy,
2327 only creating the necessary destination directories to hold the
2328 .pdf files, and ensures that any superfluous files and directo‐
2329 ries in the destination are removed (note the hide filter of
2330 non-directories being used instead of an exclude):
2331
2332 rsync -avm --del --include=’*.pdf’ -f ’hide,! */’ src/ dest
2333
2334
2335 If you didn’t want to remove superfluous destination files, the
2336 more time-honored options of "--include='*/' --exclude='*'"
2337 would work fine in place of the hide-filter (if that is more
2338 natural to you).
2339
2340 --progress
2341 This option tells rsync to print information showing the
2342 progress of the transfer. This gives a bored user something to
2343 watch. Implies --verbose if it wasn’t already specified.
2344
2345 While rsync is transferring a regular file, it updates a
2346 progress line that looks like this:
2347
2348 782448 63% 110.64kB/s 0:00:04
2349
2350
2351 In this example, the receiver has reconstructed 782448 bytes or
2352 63% of the sender’s file, which is being reconstructed at a rate
2353 of 110.64 kilobytes per second, and the transfer will finish in
2354 4 seconds if the current rate is maintained until the end.
2355
2356 These statistics can be misleading if rsync’s delta-transfer
2357 algorithm is in use. For example, if the sender’s file consists
2358 of the basis file followed by additional data, the reported rate
2359 will probably drop dramatically when the receiver gets to the
2360 literal data, and the transfer will probably take much longer to
2361 finish than the receiver estimated as it was finishing the
2362 matched part of the file.
2363
2364 When the file transfer finishes, rsync replaces the progress
2365 line with a summary line that looks like this:
2366
2367 1238099 100% 146.38kB/s 0:00:08 (xfer#5, to-check=169/396)
2368
2369
2370 In this example, the file was 1238099 bytes long in total, the
2371 average rate of transfer for the whole file was 146.38 kilobytes
2372 per second over the 8 seconds that it took to complete, it was
2373 the 5th transfer of a regular file during the current rsync ses‐
2374 sion, and there are 169 more files for the receiver to check (to
2375 see if they are up-to-date or not) remaining out of the 396
2376 total files in the file-list.
2377
2378 -P The -P option is equivalent to --partial --progress. Its pur‐
2379 pose is to make it much easier to specify these two options for
2380 a long transfer that may be interrupted.
2381
2382 --password-file
2383 This option allows you to provide a password in a file for
2384 accessing an rsync daemon. The file must not be world readable.
2385 It should contain just the password as the first line of the
2386 file (all other lines are ignored).
2387
2388 This option does not supply a password to a remote shell trans‐
2389 port such as ssh; to learn how to do that, consult the remote
2390 shell’s documentation. When accessing an rsync daemon using a
2391 remote shell as the transport, this option only comes into
2392 effect after the remote shell finishes its authentication (i.e.
2393 if you have also specified a password in the daemon’s config
2394 file).
2395
2396 --list-only
2397 This option will cause the source files to be listed instead of
2398 transferred. This option is inferred if there is a single
2399 source arg and no destination specified, so its main uses are:
2400 (1) to turn a copy command that includes a destination arg into
2401 a file-listing command, or (2) to be able to specify more than
2402 one source arg (note: be sure to include the destination). Cau‐
2403 tion: keep in mind that a source arg with a wild-card is
2404 expanded by the shell into multiple args, so it is never safe to
2405 try to list such an arg without using this option. For example:
2406
2407 rsync -av --list-only foo* dest/
2408
2409
2410 Compatibility note: when requesting a remote listing of files
2411 from an rsync that is version 2.6.3 or older, you may encounter
2412 an error if you ask for a non-recursive listing. This is
2413 because a file listing implies the --dirs option w/o --recur‐
2414 sive, and older rsyncs don’t have that option. To avoid this
2415 problem, either specify the --no-dirs option (if you don’t need
2416 to expand a directory’s content), or turn on recursion and
2417 exclude the content of subdirectories: -r --exclude='/*/*'.
2418
2419 --bwlimit=KBPS
2420 This option allows you to specify a maximum transfer rate in
2421 kilobytes per second. This option is most effective when using
2422 rsync with large files (several megabytes and up). Due to the
2423 nature of rsync transfers, blocks of data are sent, then if
2424 rsync determines the transfer was too fast, it will wait before
2425 sending the next data block. The result is an average transfer
2426 rate equaling the specified limit. A value of zero specifies no
2427 limit.
2428
2429 --write-batch=FILE
2430 Record a file that can later be applied to another identical
2431 destination with --read-batch. See the "BATCH MODE" section for
2432 details, and also the --only-write-batch option.
2433
2434 --only-write-batch=FILE
2435 Works like --write-batch, except that no updates are made on the
2436 destination system when creating the batch. This lets you
2437 transport the changes to the destination system via some other
2438 means and then apply the changes via --read-batch.
2439
2440 Note that you can feel free to write the batch directly to some
2441 portable media: if this media fills to capacity before the end
2442 of the transfer, you can just apply that partial transfer to the
2443 destination and repeat the whole process to get the rest of the
2444 changes (as long as you don’t mind a partially updated destina‐
2445 tion system while the multi-update cycle is happening).
2446
2447 Also note that you only save bandwidth when pushing changes to a
2448 remote system because this allows the batched data to be
2449 diverted from the sender into the batch file without having to
2450 flow over the wire to the receiver (when pulling, the sender is
2451 remote, and thus can’t write the batch).
2452
2453 --read-batch=FILE
2454 Apply all of the changes stored in FILE, a file previously gen‐
2455 erated by --write-batch. If FILE is -, the batch data will be
2456 read from standard input. See the "BATCH MODE" section for
2457 details.
2458
2459 --protocol=NUM
2460 Force an older protocol version to be used. This is useful for
2461 creating a batch file that is compatible with an older version
2462 of rsync. For instance, if rsync 2.6.4 is being used with the
2463 --write-batch option, but rsync 2.6.3 is what will be used to
2464 run the --read-batch option, you should use "--protocol=28" when
2465 creating the batch file to force the older protocol version to
2466 be used in the batch file (assuming you can’t upgrade the rsync
2467 on the reading system).
2468
2469 --iconv=CONVERT_SPEC
2470 Rsync can convert filenames between character sets using this
2471 option. Using a CONVERT_SPEC of "." tells rsync to look up the
2472 default character-set via the locale setting. Alternately, you
2473 can fully specify what conversion to do by giving a local and a
2474 remote charset separated by a comma in the order
2475 --iconv=LOCAL,REMOTE, e.g. --iconv=utf8,iso88591. This order
2476 ensures that the option will stay the same whether you’re push‐
2477 ing or pulling files. Finally, you can specify either
2478 --no-iconv or a CONVERT_SPEC of "-" to turn off any conversion.
2479 The default setting of this option is site-specific, and can
2480 also be affected via the RSYNC_ICONV environment variable.
2481
2482 For a list of what charset names your local iconv library sup‐
2483 ports, you can run "iconv --list".
2484
2485 If you specify the --protect-args option (-s), rsync will trans‐
2486 late the filenames you specify on the command-line that are
2487 being sent to the remote host. See also the --files-from
2488 option.
2489
2490 Note that rsync does not do any conversion of names in filter
2491 files (including include/exclude files). It is up to you to
2492 ensure that you’re specifying matching rules that can match on
2493 both sides of the transfer. For instance, you can specify extra
2494 include/exclude rules if there are filename differences on the
2495 two sides that need to be accounted for.
2496
2497 When you pass an --iconv option to an rsync daemon that allows
2498 it, the daemon uses the charset specified in its "charset" con‐
2499 figuration parameter regardless of the remote charset you actu‐
2500 ally pass. Thus, you may feel free to specify just the local
2501 charset for a daemon transfer (e.g. --iconv=utf8).
2502
2503 -4, --ipv4 or -6, --ipv6
2504 Tells rsync to prefer IPv4/IPv6 when creating sockets. This
2505 only affects sockets that rsync has direct control over, such as
2506 the outgoing socket when directly contacting an rsync daemon.
2507 See also these options in the --daemon mode section.
2508
2509 If rsync was complied without support for IPv6, the --ipv6
2510 option will have no effect. The --version output will tell you
2511 if this is the case.
2512
2513 --checksum-seed=NUM
2514 Set the checksum seed to the integer NUM. This 4 byte checksum
2515 seed is included in each block and file checksum calculation.
2516 By default the checksum seed is generated by the server and
2517 defaults to the current time() . This option is used to set a
2518 specific checksum seed, which is useful for applications that
2519 want repeatable block and file checksums, or in the case where
2520 the user wants a more random checksum seed. Setting NUM to 0
2521 causes rsync to use the default of time() for checksum seed.
2522
2523
2525 The options allowed when starting an rsync daemon are as follows:
2526
2527 --daemon
2528 This tells rsync that it is to run as a daemon. The daemon you
2529 start running may be accessed using an rsync client using the
2530 host::module or rsync://host/module/ syntax.
2531
2532 If standard input is a socket then rsync will assume that it is
2533 being run via inetd, otherwise it will detach from the current
2534 terminal and become a background daemon. The daemon will read
2535 the config file (rsyncd.conf) on each connect made by a client
2536 and respond to requests accordingly. See the rsyncd.conf(5) man
2537 page for more details.
2538
2539 --address
2540 By default rsync will bind to the wildcard address when run as a
2541 daemon with the --daemon option. The --address option allows
2542 you to specify a specific IP address (or hostname) to bind to.
2543 This makes virtual hosting possible in conjunction with the
2544 --config option. See also the "address" global option in the
2545 rsyncd.conf manpage.
2546
2547 --bwlimit=KBPS
2548 This option allows you to specify a maximum transfer rate in
2549 kilobytes per second for the data the daemon sends. The client
2550 can still specify a smaller --bwlimit value, but their requested
2551 value will be rounded down if they try to exceed it. See the
2552 client version of this option (above) for some extra details.
2553
2554 --config=FILE
2555 This specifies an alternate config file than the default. This
2556 is only relevant when --daemon is specified. The default is
2557 /etc/rsyncd.conf unless the daemon is running over a remote
2558 shell program and the remote user is not the super-user; in that
2559 case the default is rsyncd.conf in the current directory (typi‐
2560 cally $HOME).
2561
2562 --no-detach
2563 When running as a daemon, this option instructs rsync to not
2564 detach itself and become a background process. This option is
2565 required when running as a service on Cygwin, and may also be
2566 useful when rsync is supervised by a program such as daemontools
2567 or AIX’s System Resource Controller. --no-detach is also recom‐
2568 mended when rsync is run under a debugger. This option has no
2569 effect if rsync is run from inetd or sshd.
2570
2571 --port=PORT
2572 This specifies an alternate TCP port number for the daemon to
2573 listen on rather than the default of 873. See also the "port"
2574 global option in the rsyncd.conf manpage.
2575
2576 --log-file=FILE
2577 This option tells the rsync daemon to use the given log-file
2578 name instead of using the "log file" setting in the config file.
2579
2580 --log-file-format=FORMAT
2581 This option tells the rsync daemon to use the given FORMAT
2582 string instead of using the "log format" setting in the config
2583 file. It also enables "transfer logging" unless the string is
2584 empty, in which case transfer logging is turned off.
2585
2586 --sockopts
2587 This overrides the socket options setting in the rsyncd.conf
2588 file and has the same syntax.
2589
2590 -v, --verbose
2591 This option increases the amount of information the daemon logs
2592 during its startup phase. After the client connects, the dae‐
2593 mon’s verbosity level will be controlled by the options that the
2594 client used and the "max verbosity" setting in the module’s con‐
2595 fig section.
2596
2597 -4, --ipv4 or -6, --ipv6
2598 Tells rsync to prefer IPv4/IPv6 when creating the incoming sock‐
2599 ets that the rsync daemon will use to listen for connections.
2600 One of these options may be required in older versions of Linux
2601 to work around an IPv6 bug in the kernel (if you see an "address
2602 already in use" error when nothing else is using the port, try
2603 specifying --ipv6 or --ipv4 when starting the daemon).
2604
2605 If rsync was complied without support for IPv6, the --ipv6
2606 option will have no effect. The --version output will tell you
2607 if this is the case.
2608
2609 -h, --help
2610 When specified after --daemon, print a short help page describ‐
2611 ing the options available for starting an rsync daemon.
2612
2613
2615 The filter rules allow for flexible selection of which files to trans‐
2616 fer (include) and which files to skip (exclude). The rules either
2617 directly specify include/exclude patterns or they specify a way to
2618 acquire more include/exclude patterns (e.g. to read them from a file).
2619
2620 As the list of files/directories to transfer is built, rsync checks
2621 each name to be transferred against the list of include/exclude pat‐
2622 terns in turn, and the first matching pattern is acted on: if it is an
2623 exclude pattern, then that file is skipped; if it is an include pattern
2624 then that filename is not skipped; if no matching pattern is found,
2625 then the filename is not skipped.
2626
2627 Rsync builds an ordered list of filter rules as specified on the com‐
2628 mand-line. Filter rules have the following syntax:
2629
2630 RULE [PATTERN_OR_FILENAME]
2631 RULE,MODIFIERS [PATTERN_OR_FILENAME]
2632
2633
2634 You have your choice of using either short or long RULE names, as
2635 described below. If you use a short-named rule, the ’,’ separating the
2636 RULE from the MODIFIERS is optional. The PATTERN or FILENAME that fol‐
2637 lows (when present) must come after either a single space or an under‐
2638 score (_). Here are the available rule prefixes:
2639
2640 exclude, - specifies an exclude pattern.
2641 include, + specifies an include pattern.
2642 merge, . specifies a merge-file to read for more rules.
2643 dir-merge, : specifies a per-directory merge-file.
2644 hide, H specifies a pattern for hiding files from the transfer.
2645 show, S files that match the pattern are not hidden.
2646 protect, P specifies a pattern for protecting files from dele‐
2647 tion.
2648 risk, R files that match the pattern are not protected.
2649 clear, ! clears the current include/exclude list (takes no arg)
2650
2651
2652 When rules are being read from a file, empty lines are ignored, as are
2653 comment lines that start with a "#".
2654
2655 Note that the --include/--exclude command-line options do not allow the
2656 full range of rule parsing as described above -- they only allow the
2657 specification of include/exclude patterns plus a "!" token to clear the
2658 list (and the normal comment parsing when rules are read from a file).
2659 If a pattern does not begin with "- " (dash, space) or "+ " (plus,
2660 space), then the rule will be interpreted as if "+ " (for an include
2661 option) or "- " (for an exclude option) were prefixed to the string. A
2662 --filter option, on the other hand, must always contain either a short
2663 or long rule name at the start of the rule.
2664
2665 Note also that the --filter, --include, and --exclude options take one
2666 rule/pattern each. To add multiple ones, you can repeat the options on
2667 the command-line, use the merge-file syntax of the --filter option, or
2668 the --include-from/--exclude-from options.
2669
2671 You can include and exclude files by specifying patterns using the "+",
2672 "-", etc. filter rules (as introduced in the FILTER RULES section
2673 above). The include/exclude rules each specify a pattern that is
2674 matched against the names of the files that are going to be trans‐
2675 ferred. These patterns can take several forms:
2676
2677 o if the pattern starts with a / then it is anchored to a particu‐
2678 lar spot in the hierarchy of files, otherwise it is matched
2679 against the end of the pathname. This is similar to a leading ^
2680 in regular expressions. Thus "/foo" would match a name of "foo"
2681 at either the "root of the transfer" (for a global rule) or in
2682 the merge-file’s directory (for a per-directory rule). An
2683 unqualified "foo" would match a name of "foo" anywhere in the
2684 tree because the algorithm is applied recursively from the top
2685 down; it behaves as if each path component gets a turn at being
2686 the end of the filename. Even the unanchored "sub/foo" would
2687 match at any point in the hierarchy where a "foo" was found
2688 within a directory named "sub". See the section on ANCHORING
2689 INCLUDE/EXCLUDE PATTERNS for a full discussion of how to specify
2690 a pattern that matches at the root of the transfer.
2691
2692 o if the pattern ends with a / then it will only match a direc‐
2693 tory, not a regular file, symlink, or device.
2694
2695 o rsync chooses between doing a simple string match and wildcard
2696 matching by checking if the pattern contains one of these three
2697 wildcard characters: ’*’, ’?’, and ’[’ .
2698
2699 o a ’*’ matches any path component, but it stops at slashes.
2700
2701 o use ’**’ to match anything, including slashes.
2702
2703 o a ’?’ matches any character except a slash (/).
2704
2705 o a ’[’ introduces a character class, such as [a-z] or
2706 [[:alpha:]].
2707
2708 o in a wildcard pattern, a backslash can be used to escape a wild‐
2709 card character, but it is matched literally when no wildcards
2710 are present.
2711
2712 o if the pattern contains a / (not counting a trailing /) or a
2713 "**", then it is matched against the full pathname, including
2714 any leading directories. If the pattern doesn’t contain a / or a
2715 "**", then it is matched only against the final component of the
2716 filename. (Remember that the algorithm is applied recursively
2717 so "full filename" can actually be any portion of a path from
2718 the starting directory on down.)
2719
2720 o a trailing "dir_name/***" will match both the directory (as if
2721 "dir_name/" had been specified) and everything in the directory
2722 (as if "dir_name/**" had been specified). This behavior was
2723 added in version 2.6.7.
2724
2725
2726 Note that, when using the --recursive (-r) option (which is implied by
2727 -a), every subcomponent of every path is visited from the top down, so
2728 include/exclude patterns get applied recursively to each subcomponent’s
2729 full name (e.g. to include "/foo/bar/baz" the subcomponents "/foo" and
2730 "/foo/bar" must not be excluded). The exclude patterns actually
2731 short-circuit the directory traversal stage when rsync finds the files
2732 to send. If a pattern excludes a particular parent directory, it can
2733 render a deeper include pattern ineffectual because rsync did not
2734 descend through that excluded section of the hierarchy. This is par‐
2735 ticularly important when using a trailing ’*’ rule. For instance, this
2736 won’t work:
2737
2738 + /some/path/this-file-will-not-be-found
2739 + /file-is-included
2740 - *
2741
2742
2743 This fails because the parent directory "some" is excluded by the ’*’
2744 rule, so rsync never visits any of the files in the "some" or
2745 "some/path" directories. One solution is to ask for all directories in
2746 the hierarchy to be included by using a single rule: "+ */" (put it
2747 somewhere before the "- *" rule), and perhaps use the
2748 --prune-empty-dirs option. Another solution is to add specific include
2749 rules for all the parent dirs that need to be visited. For instance,
2750 this set of rules works fine:
2751
2752 + /some/
2753 + /some/path/
2754 + /some/path/this-file-is-found
2755 + /file-also-included
2756 - *
2757
2758
2759 Here are some examples of exclude/include matching:
2760
2761 o "- *.o" would exclude all names matching *.o
2762
2763 o "- /foo" would exclude a file (or directory) named foo in the
2764 transfer-root directory
2765
2766 o "- foo/" would exclude any directory named foo
2767
2768 o "- /foo/*/bar" would exclude any file named bar which is at two
2769 levels below a directory named foo in the transfer-root direc‐
2770 tory
2771
2772 o "- /foo/**/bar" would exclude any file named bar two or more
2773 levels below a directory named foo in the transfer-root direc‐
2774 tory
2775
2776 o The combination of "+ */", "+ *.c", and "- *" would include all
2777 directories and C source files but nothing else (see also the
2778 --prune-empty-dirs option)
2779
2780 o The combination of "+ foo/", "+ foo/bar.c", and "- *" would
2781 include only the foo directory and foo/bar.c (the foo directory
2782 must be explicitly included or it would be excluded by the "*")
2783
2784
2785 The following modifiers are accepted after a "+" or "-":
2786
2787 o A / specifies that the include/exclude rule should be matched
2788 against the absolute pathname of the current item. For example,
2789 "-/ /etc/passwd" would exclude the passwd file any time the
2790 transfer was sending files from the "/etc" directory, and "-/
2791 subdir/foo" would always exclude "foo" when it is in a dir named
2792 "subdir", even if "foo" is at the root of the current transfer.
2793
2794 o A ! specifies that the include/exclude should take effect if the
2795 pattern fails to match. For instance, "-! */" would exclude all
2796 non-directories.
2797
2798 o A C is used to indicate that all the global CVS-exclude rules
2799 should be inserted as excludes in place of the "-C". No arg
2800 should follow.
2801
2802 o An s is used to indicate that the rule applies to the sending
2803 side. When a rule affects the sending side, it prevents files
2804 from being transferred. The default is for a rule to affect
2805 both sides unless --delete-excluded was specified, in which case
2806 default rules become sender-side only. See also the hide (H)
2807 and show (S) rules, which are an alternate way to specify send‐
2808 ing-side includes/excludes.
2809
2810 o An r is used to indicate that the rule applies to the receiving
2811 side. When a rule affects the receiving side, it prevents files
2812 from being deleted. See the s modifier for more info. See also
2813 the protect (P) and risk (R) rules, which are an alternate way
2814 to specify receiver-side includes/excludes.
2815
2816 o A p indicates that a rule is perishable, meaning that it is
2817 ignored in directories that are being deleted. For instance,
2818 the -C option’s default rules that exclude things like "CVS" and
2819 "*.o" are marked as perishable, and will not prevent a directory
2820 that was removed on the source from being deleted on the desti‐
2821 nation.
2822
2823
2825 You can merge whole files into your filter rules by specifying either a
2826 merge (.) or a dir-merge (:) filter rule (as introduced in the FILTER
2827 RULES section above).
2828
2829 There are two kinds of merged files -- single-instance (’.’) and
2830 per-directory (’:’). A single-instance merge file is read one time,
2831 and its rules are incorporated into the filter list in the place of the
2832 "." rule. For per-directory merge files, rsync will scan every direc‐
2833 tory that it traverses for the named file, merging its contents when
2834 the file exists into the current list of inherited rules. These
2835 per-directory rule files must be created on the sending side because it
2836 is the sending side that is being scanned for the available files to
2837 transfer. These rule files may also need to be transferred to the
2838 receiving side if you want them to affect what files don’t get deleted
2839 (see PER-DIRECTORY RULES AND DELETE below).
2840
2841 Some examples:
2842
2843 merge /etc/rsync/default.rules
2844 . /etc/rsync/default.rules
2845 dir-merge .per-dir-filter
2846 dir-merge,n- .non-inherited-per-dir-excludes
2847 :n- .non-inherited-per-dir-excludes
2848
2849
2850 The following modifiers are accepted after a merge or dir-merge rule:
2851
2852 o A - specifies that the file should consist of only exclude pat‐
2853 terns, with no other rule-parsing except for in-file comments.
2854
2855 o A + specifies that the file should consist of only include pat‐
2856 terns, with no other rule-parsing except for in-file comments.
2857
2858 o A C is a way to specify that the file should be read in a
2859 CVS-compatible manner. This turns on ’n’, ’w’, and ’-’, but
2860 also allows the list-clearing token (!) to be specified. If no
2861 filename is provided, ".cvsignore" is assumed.
2862
2863 o A e will exclude the merge-file name from the transfer; e.g.
2864 "dir-merge,e .rules" is like "dir-merge .rules" and "- .rules".
2865
2866 o An n specifies that the rules are not inherited by subdirecto‐
2867 ries.
2868
2869 o A w specifies that the rules are word-split on whitespace
2870 instead of the normal line-splitting. This also turns off com‐
2871 ments. Note: the space that separates the prefix from the rule
2872 is treated specially, so "- foo + bar" is parsed as two rules
2873 (assuming that prefix-parsing wasn’t also disabled).
2874
2875 o You may also specify any of the modifiers for the "+" or "-"
2876 rules (above) in order to have the rules that are read in from
2877 the file default to having that modifier set (except for the !
2878 modifier, which would not be useful). For instance, "merge,-/
2879 .excl" would treat the contents of .excl as absolute-path
2880 excludes, while "dir-merge,s .filt" and ":sC" would each make
2881 all their per-directory rules apply only on the sending side.
2882 If the merge rule specifies sides to affect (via the s or r mod‐
2883 ifier or both), then the rules in the file must not specify
2884 sides (via a modifier or a rule prefix such as hide).
2885
2886
2887 Per-directory rules are inherited in all subdirectories of the direc‐
2888 tory where the merge-file was found unless the ’n’ modifier was used.
2889 Each subdirectory’s rules are prefixed to the inherited per-directory
2890 rules from its parents, which gives the newest rules a higher priority
2891 than the inherited rules. The entire set of dir-merge rules are
2892 grouped together in the spot where the merge-file was specified, so it
2893 is possible to override dir-merge rules via a rule that got specified
2894 earlier in the list of global rules. When the list-clearing rule ("!")
2895 is read from a per-directory file, it only clears the inherited rules
2896 for the current merge file.
2897
2898 Another way to prevent a single rule from a dir-merge file from being
2899 inherited is to anchor it with a leading slash. Anchored rules in a
2900 per-directory merge-file are relative to the merge-file’s directory, so
2901 a pattern "/foo" would only match the file "foo" in the directory where
2902 the dir-merge filter file was found.
2903
2904 Here’s an example filter file which you’d specify via --filter=".
2905 file":
2906
2907 merge /home/user/.global-filter
2908 - *.gz
2909 dir-merge .rules
2910 + *.[ch]
2911 - *.o
2912
2913
2914 This will merge the contents of the /home/user/.global-filter file at
2915 the start of the list and also turns the ".rules" filename into a
2916 per-directory filter file. All rules read in prior to the start of the
2917 directory scan follow the global anchoring rules (i.e. a leading slash
2918 matches at the root of the transfer).
2919
2920 If a per-directory merge-file is specified with a path that is a parent
2921 directory of the first transfer directory, rsync will scan all the par‐
2922 ent dirs from that starting point to the transfer directory for the
2923 indicated per-directory file. For instance, here is a common filter
2924 (see -F):
2925
2926 --filter=': /.rsync-filter'
2927
2928
2929 That rule tells rsync to scan for the file .rsync-filter in all direc‐
2930 tories from the root down through the parent directory of the transfer
2931 prior to the start of the normal directory scan of the file in the
2932 directories that are sent as a part of the transfer. (Note: for an
2933 rsync daemon, the root is always the same as the module’s "path".)
2934
2935 Some examples of this pre-scanning for per-directory files:
2936
2937 rsync -avF /src/path/ /dest/dir
2938 rsync -av --filter=': ../../.rsync-filter' /src/path/ /dest/dir
2939 rsync -av --filter=': .rsync-filter' /src/path/ /dest/dir
2940
2941
2942 The first two commands above will look for ".rsync-filter" in "/" and
2943 "/src" before the normal scan begins looking for the file in
2944 "/src/path" and its subdirectories. The last command avoids the par‐
2945 ent-dir scan and only looks for the ".rsync-filter" files in each
2946 directory that is a part of the transfer.
2947
2948 If you want to include the contents of a ".cvsignore" in your patterns,
2949 you should use the rule ":C", which creates a dir-merge of the .cvsig‐
2950 nore file, but parsed in a CVS-compatible manner. You can use this to
2951 affect where the --cvs-exclude (-C) option’s inclusion of the
2952 per-directory .cvsignore file gets placed into your rules by putting
2953 the ":C" wherever you like in your filter rules. Without this, rsync
2954 would add the dir-merge rule for the .cvsignore file at the end of all
2955 your other rules (giving it a lower priority than your command-line
2956 rules). For example:
2957
2958 cat <<EOT | rsync -avC --filter='. -' a/ b
2959 + foo.o
2960 :C
2961 - *.old
2962 EOT
2963 rsync -avC --include=foo.o -f :C --exclude='*.old' a/ b
2964
2965
2966 Both of the above rsync commands are identical. Each one will merge
2967 all the per-directory .cvsignore rules in the middle of the list rather
2968 than at the end. This allows their dir-specific rules to supersede the
2969 rules that follow the :C instead of being subservient to all your
2970 rules. To affect the other CVS exclude rules (i.e. the default list of
2971 exclusions, the contents of $HOME/.cvsignore, and the value of $CVSIG‐
2972 NORE) you should omit the -C command-line option and instead insert a
2973 "-C" rule into your filter rules; e.g. "--filter=-C".
2974
2976 You can clear the current include/exclude list by using the "!" filter
2977 rule (as introduced in the FILTER RULES section above). The "current"
2978 list is either the global list of rules (if the rule is encountered
2979 while parsing the filter options) or a set of per-directory rules
2980 (which are inherited in their own sub-list, so a subdirectory can use
2981 this to clear out the parent’s rules).
2982
2984 As mentioned earlier, global include/exclude patterns are anchored at
2985 the "root of the transfer" (as opposed to per-directory patterns, which
2986 are anchored at the merge-file’s directory). If you think of the
2987 transfer as a subtree of names that are being sent from sender to
2988 receiver, the transfer-root is where the tree starts to be duplicated
2989 in the destination directory. This root governs where patterns that
2990 start with a / match.
2991
2992 Because the matching is relative to the transfer-root, changing the
2993 trailing slash on a source path or changing your use of the --relative
2994 option affects the path you need to use in your matching (in addition
2995 to changing how much of the file tree is duplicated on the destination
2996 host). The following examples demonstrate this.
2997
2998 Let’s say that we want to match two source files, one with an absolute
2999 path of "/home/me/foo/bar", and one with a path of "/home/you/bar/baz".
3000 Here is how the various command choices differ for a 2-source transfer:
3001
3002 Example cmd: rsync -a /home/me /home/you /dest
3003 +/- pattern: /me/foo/bar
3004 +/- pattern: /you/bar/baz
3005 Target file: /dest/me/foo/bar
3006 Target file: /dest/you/bar/baz
3007
3008
3009 Example cmd: rsync -a /home/me/ /home/you/ /dest
3010 +/- pattern: /foo/bar (note missing "me")
3011 +/- pattern: /bar/baz (note missing "you")
3012 Target file: /dest/foo/bar
3013 Target file: /dest/bar/baz
3014
3015
3016 Example cmd: rsync -a --relative /home/me/ /home/you /dest
3017 +/- pattern: /home/me/foo/bar (note full path)
3018 +/- pattern: /home/you/bar/baz (ditto)
3019 Target file: /dest/home/me/foo/bar
3020 Target file: /dest/home/you/bar/baz
3021
3022
3023 Example cmd: cd /home; rsync -a --relative me/foo you/ /dest
3024 +/- pattern: /me/foo/bar (starts at specified path)
3025 +/- pattern: /you/bar/baz (ditto)
3026 Target file: /dest/me/foo/bar
3027 Target file: /dest/you/bar/baz
3028
3029
3030 The easiest way to see what name you should filter is to just look at
3031 the output when using --verbose and put a / in front of the name (use
3032 the --dry-run option if you’re not yet ready to copy any files).
3033
3035 Without a delete option, per-directory rules are only relevant on the
3036 sending side, so you can feel free to exclude the merge files them‐
3037 selves without affecting the transfer. To make this easy, the ’e’ mod‐
3038 ifier adds this exclude for you, as seen in these two equivalent com‐
3039 mands:
3040
3041 rsync -av --filter=': .excl' --exclude=.excl host:src/dir /dest
3042 rsync -av --filter=':e .excl' host:src/dir /dest
3043
3044
3045 However, if you want to do a delete on the receiving side AND you want
3046 some files to be excluded from being deleted, you’ll need to be sure
3047 that the receiving side knows what files to exclude. The easiest way
3048 is to include the per-directory merge files in the transfer and use
3049 --delete-after, because this ensures that the receiving side gets all
3050 the same exclude rules as the sending side before it tries to delete
3051 anything:
3052
3053 rsync -avF --delete-after host:src/dir /dest
3054
3055
3056 However, if the merge files are not a part of the transfer, you’ll need
3057 to either specify some global exclude rules (i.e. specified on the com‐
3058 mand line), or you’ll need to maintain your own per-directory merge
3059 files on the receiving side. An example of the first is this (assume
3060 that the remote .rules files exclude themselves):
3061
3062 rsync -av --filter=’: .rules’ --filter=’. /my/extra.rules’
3063 --delete host:src/dir /dest
3064
3065
3066 In the above example the extra.rules file can affect both sides of the
3067 transfer, but (on the sending side) the rules are subservient to the
3068 rules merged from the .rules files because they were specified after
3069 the per-directory merge rule.
3070
3071 In one final example, the remote side is excluding the .rsync-filter
3072 files from the transfer, but we want to use our own .rsync-filter files
3073 to control what gets deleted on the receiving side. To do this we must
3074 specifically exclude the per-directory merge files (so that they don’t
3075 get deleted) and then put rules into the local files to control what
3076 else should not get deleted. Like one of these commands:
3077
3078 rsync -av --filter=':e /.rsync-filter' --delete \
3079 host:src/dir /dest
3080 rsync -avFF --delete host:src/dir /dest
3081
3082
3084 Batch mode can be used to apply the same set of updates to many identi‐
3085 cal systems. Suppose one has a tree which is replicated on a number of
3086 hosts. Now suppose some changes have been made to this source tree and
3087 those changes need to be propagated to the other hosts. In order to do
3088 this using batch mode, rsync is run with the write-batch option to
3089 apply the changes made to the source tree to one of the destination
3090 trees. The write-batch option causes the rsync client to store in a
3091 "batch file" all the information needed to repeat this operation
3092 against other, identical destination trees.
3093
3094 Generating the batch file once saves having to perform the file status,
3095 checksum, and data block generation more than once when updating multi‐
3096 ple destination trees. Multicast transport protocols can be used to
3097 transfer the batch update files in parallel to many hosts at once,
3098 instead of sending the same data to every host individually.
3099
3100 To apply the recorded changes to another destination tree, run rsync
3101 with the read-batch option, specifying the name of the same batch file,
3102 and the destination tree. Rsync updates the destination tree using the
3103 information stored in the batch file.
3104
3105 For your convenience, a script file is also created when the
3106 write-batch option is used: it will be named the same as the batch
3107 file with ".sh" appended. This script file contains a command-line
3108 suitable for updating a destination tree using the associated batch
3109 file. It can be executed using a Bourne (or Bourne-like) shell, option‐
3110 ally passing in an alternate destination tree pathname which is then
3111 used instead of the original destination path. This is useful when the
3112 destination tree path on the current host differs from the one used to
3113 create the batch file.
3114
3115 Examples:
3116
3117 $ rsync --write-batch=foo -a host:/source/dir/ /adest/dir/
3118 $ scp foo* remote:
3119 $ ssh remote ./foo.sh /bdest/dir/
3120
3121
3122 $ rsync --write-batch=foo -a /source/dir/ /adest/dir/
3123 $ ssh remote rsync --read-batch=- -a /bdest/dir/ <foo
3124
3125
3126 In these examples, rsync is used to update /adest/dir/ from
3127 /source/dir/ and the information to repeat this operation is stored in
3128 "foo" and "foo.sh". The host "remote" is then updated with the batched
3129 data going into the directory /bdest/dir. The differences between the
3130 two examples reveals some of the flexibility you have in how you deal
3131 with batches:
3132
3133 o The first example shows that the initial copy doesn’t have to be
3134 local -- you can push or pull data to/from a remote host using
3135 either the remote-shell syntax or rsync daemon syntax, as
3136 desired.
3137
3138 o The first example uses the created "foo.sh" file to get the
3139 right rsync options when running the read-batch command on the
3140 remote host.
3141
3142 o The second example reads the batch data via standard input so
3143 that the batch file doesn’t need to be copied to the remote
3144 machine first. This example avoids the foo.sh script because it
3145 needed to use a modified --read-batch option, but you could edit
3146 the script file if you wished to make use of it (just be sure
3147 that no other option is trying to use standard input, such as
3148 the "--exclude-from=-" option).
3149
3150
3151 Caveats:
3152
3153 The read-batch option expects the destination tree that it is updating
3154 to be identical to the destination tree that was used to create the
3155 batch update fileset. When a difference between the destination trees
3156 is encountered the update might be discarded with a warning (if the
3157 file appears to be up-to-date already) or the file-update may be
3158 attempted and then, if the file fails to verify, the update discarded
3159 with an error. This means that it should be safe to re-run a
3160 read-batch operation if the command got interrupted. If you wish to
3161 force the batched-update to always be attempted regardless of the
3162 file’s size and date, use the -I option (when reading the batch). If
3163 an error occurs, the destination tree will probably be in a partially
3164 updated state. In that case, rsync can be used in its regular
3165 (non-batch) mode of operation to fix up the destination tree.
3166
3167 The rsync version used on all destinations must be at least as new as
3168 the one used to generate the batch file. Rsync will die with an error
3169 if the protocol version in the batch file is too new for the
3170 batch-reading rsync to handle. See also the --protocol option for a
3171 way to have the creating rsync generate a batch file that an older
3172 rsync can understand. (Note that batch files changed format in version
3173 2.6.3, so mixing versions older than that with newer versions will not
3174 work.)
3175
3176 When reading a batch file, rsync will force the value of certain
3177 options to match the data in the batch file if you didn’t set them to
3178 the same as the batch-writing command. Other options can (and should)
3179 be changed. For instance --write-batch changes to --read-batch,
3180 --files-from is dropped, and the --filter/--include/--exclude options
3181 are not needed unless one of the --delete options is specified.
3182
3183 The code that creates the BATCH.sh file transforms any fil‐
3184 ter/include/exclude options into a single list that is appended as a
3185 "here" document to the shell script file. An advanced user can use
3186 this to modify the exclude list if a change in what gets deleted by
3187 --delete is desired. A normal user can ignore this detail and just use
3188 the shell script as an easy way to run the appropriate --read-batch
3189 command for the batched data.
3190
3191 The original batch mode in rsync was based on "rsync+", but the latest
3192 version uses a new implementation.
3193
3195 Three basic behaviors are possible when rsync encounters a symbolic
3196 link in the source directory.
3197
3198 By default, symbolic links are not transferred at all. A message
3199 "skipping non-regular" file is emitted for any symlinks that exist.
3200
3201 If --links is specified, then symlinks are recreated with the same tar‐
3202 get on the destination. Note that --archive implies --links.
3203
3204 If --copy-links is specified, then symlinks are "collapsed" by copying
3205 their referent, rather than the symlink.
3206
3207 Rsync can also distinguish "safe" and "unsafe" symbolic links. An
3208 example where this might be used is a web site mirror that wishes to
3209 ensure that the rsync module that is copied does not include symbolic
3210 links to /etc/passwd in the public section of the site. Using
3211 --copy-unsafe-links will cause any links to be copied as the file they
3212 point to on the destination. Using --safe-links will cause unsafe
3213 links to be omitted altogether. (Note that you must specify --links
3214 for --safe-links to have any effect.)
3215
3216 Symbolic links are considered unsafe if they are absolute symlinks
3217 (start with /), empty, or if they contain enough ".." components to
3218 ascend from the directory being copied.
3219
3220 Here’s a summary of how the symlink options are interpreted. The list
3221 is in order of precedence, so if your combination of options isn’t men‐
3222 tioned, use the first line that is a complete subset of your options:
3223
3224 --copy-links
3225 Turn all symlinks into normal files (leaving no symlinks for any
3226 other options to affect).
3227
3228 --links --copy-unsafe-links
3229 Turn all unsafe symlinks into files and duplicate all safe sym‐
3230 links.
3231
3232 --copy-unsafe-links
3233 Turn all unsafe symlinks into files, noisily skip all safe sym‐
3234 links.
3235
3236 --links --safe-links
3237 Duplicate safe symlinks and skip unsafe ones.
3238
3239 --links
3240 Duplicate all symlinks.
3241
3243 rsync occasionally produces error messages that may seem a little cryp‐
3244 tic. The one that seems to cause the most confusion is "protocol ver‐
3245 sion mismatch -- is your shell clean?".
3246
3247 This message is usually caused by your startup scripts or remote shell
3248 facility producing unwanted garbage on the stream that rsync is using
3249 for its transport. The way to diagnose this problem is to run your
3250 remote shell like this:
3251
3252 ssh remotehost /bin/true > out.dat
3253
3254
3255 then look at out.dat. If everything is working correctly then out.dat
3256 should be a zero length file. If you are getting the above error from
3257 rsync then you will probably find that out.dat contains some text or
3258 data. Look at the contents and try to work out what is producing it.
3259 The most common cause is incorrectly configured shell startup scripts
3260 (such as .cshrc or .profile) that contain output statements for
3261 non-interactive logins.
3262
3263 If you are having trouble debugging filter patterns, then try specify‐
3264 ing the -vv option. At this level of verbosity rsync will show why
3265 each individual file is included or excluded.
3266
3268 0 Success
3269
3270 1 Syntax or usage error
3271
3272 2 Protocol incompatibility
3273
3274 3 Errors selecting input/output files, dirs
3275
3276 4 Requested action not supported: an attempt was made to manipu‐
3277 late 64-bit files on a platform that cannot support them; or an
3278 option was specified that is supported by the client and not by
3279 the server.
3280
3281 5 Error starting client-server protocol
3282
3283 6 Daemon unable to append to log-file
3284
3285 10 Error in socket I/O
3286
3287 11 Error in file I/O
3288
3289 12 Error in rsync protocol data stream
3290
3291 13 Errors with program diagnostics
3292
3293 14 Error in IPC code
3294
3295 20 Received SIGUSR1 or SIGINT
3296
3297 21 Some error returned by waitpid()
3298
3299 22 Error allocating core memory buffers
3300
3301 23 Partial transfer due to error
3302
3303 24 Partial transfer due to vanished source files
3304
3305 25 The --max-delete limit stopped deletions
3306
3307 30 Timeout in data send/receive
3308
3309 35 Timeout waiting for daemon connection
3310
3311
3313 CVSIGNORE
3314 The CVSIGNORE environment variable supplements any ignore pat‐
3315 terns in .cvsignore files. See the --cvs-exclude option for more
3316 details.
3317
3318 RSYNC_ICONV
3319 Specify a default --iconv setting using this environment vari‐
3320 able. (First supported in 3.0.0.)
3321
3322 RSYNC_RSH
3323 The RSYNC_RSH environment variable allows you to override the
3324 default shell used as the transport for rsync. Command line
3325 options are permitted after the command name, just as in the -e
3326 option.
3327
3328 RSYNC_PROXY
3329 The RSYNC_PROXY environment variable allows you to redirect your
3330 rsync client to use a web proxy when connecting to a rsync dae‐
3331 mon. You should set RSYNC_PROXY to a hostname:port pair.
3332
3333 RSYNC_PASSWORD
3334 Setting RSYNC_PASSWORD to the required password allows you to
3335 run authenticated rsync connections to an rsync daemon without
3336 user intervention. Note that this does not supply a password to
3337 a remote shell transport such as ssh; to learn how to do that,
3338 consult the remote shell’s documentation.
3339
3340 USER or LOGNAME
3341 The USER or LOGNAME environment variables are used to determine
3342 the default username sent to an rsync daemon. If neither is
3343 set, the username defaults to "nobody".
3344
3345 HOME The HOME environment variable is used to find the user’s default
3346 .cvsignore file.
3347
3348
3350 /etc/rsyncd.conf or rsyncd.conf
3351
3353 rsyncd.conf(5)
3354
3356 times are transferred as *nix time_t values
3357
3358 When transferring to FAT filesystems rsync may re-sync unmodified
3359 files. See the comments on the --modify-window option.
3360
3361 file permissions, devices, etc. are transferred as native numerical
3362 values
3363
3364 see also the comments on the --delete option
3365
3366 Please report bugs! See the web site at http://rsync.samba.org/
3367
3369 This man page is current for version 3.0.8 of rsync.
3370
3372 The options --server and --sender are used internally by rsync, and
3373 should never be typed by a user under normal circumstances. Some
3374 awareness of these options may be needed in certain scenarios, such as
3375 when setting up a login that can only run an rsync command. For
3376 instance, the support directory of the rsync distribution has an exam‐
3377 ple script named rrsync (for restricted rsync) that can be used with a
3378 restricted ssh login.
3379
3381 rsync is distributed under the GNU public license. See the file COPY‐
3382 ING for details.
3383
3384 A WEB site is available at http://rsync.samba.org/. The site includes
3385 an FAQ-O-Matic which may cover questions unanswered by this manual
3386 page.
3387
3388 The primary ftp site for rsync is ftp://rsync.samba.org/pub/rsync.
3389
3390 We would be delighted to hear from you if you like this program.
3391 Please contact the mailing-list at rsync@lists.samba.org.
3392
3393 This program uses the excellent zlib compression library written by
3394 Jean-loup Gailly and Mark Adler.
3395
3397 Special thanks go out to: John Van Essen, Matt McCutchen, Wesley W.
3398 Terpstra, David Dykstra, Jos Backus, Sebastian Krahmer, Martin Pool,
3399 and our gone-but-not-forgotten compadre, J.W. Schultz.
3400
3401 Thanks also to Richard Brent, Brendan Mackay, Bill Waite, Stephen Roth‐
3402 well and David Bell. I’ve probably missed some people, my apologies if
3403 I have.
3404
3406 rsync was originally written by Andrew Tridgell and Paul Mackerras.
3407 Many people have later contributed to it. It is currently maintained
3408 by Wayne Davison.
3409
3410 Mailing lists for support and development are available at
3411 http://lists.samba.org
3412
3413
3414
3415 26 Mar 2011 rsync(1)