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