summaryrefslogtreecommitdiff
path: root/doc/rsync.texinfo
blob: 71426a7ca59a3af216e483373b4d153546033e75 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
\input texinfo
@setfilename rsync.info
@settitle rsync
@c %** end of header

@titlepage
@sp 10
@title rsync - fast, flexible file transfer program

@c The copyright page
@page
@vskip 0pt plus 1filll
Copyright @copyright{} 2002 by Martin Pool @email{mbp@@samba.org}

Copyright @copyright{} 1996--2001 by Andrew Tridgell @email{tridge@@samba.org}
@end titlepage

@iftex
@contents
@end iftex

@ifnottex
@node Top, Overview, (dir), (dir)
@top rsync

rsync is a flexible program for efficiently copying files or directory
trees.

This manual documents rsync 2.5.  It is not yet complete and should be
consulted in conjunction with the rsync manual page.

Copyright @copyright{} 2002 by Martin Pool @email{mbp@@samba.org}.

Copyright @copyright{} 1996--2001 by Andrew Tridgell @email{tridge@@samba.org}.

@menu
* Overview::                    Tutorial section
* Invoking rsync::              
* Daemon mode::                 rsync listens for connections on its own socket

* Concept Index::               
* Option Index::                
@end menu

@end ifnottex

@node Overview, Invoking rsync, Top, Top
@chapter Overview

rsync is a program for efficiently copying files or directory trees.
rsync has many options to select which files will be copied and how
they are to be transferred.  It may be used as an alternative to @sc{ftp},
@sc{http}, @command{scp} or @command{rcp}.

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

rsync's command line syntax is analogous to @command{cp},
@command{rcp} and @command{scp}:

@example
rsync [@var{options}] @var{source} @var{destination}
@end example

Filenames may be prefixed by a hostname to indicate a remote file.
(@xref{Local and remote}.)

Some of the additional features of rsync are:

@itemize @bullet

@item support for copying links, devices, owners, groups and permissions

@item exclude and exclude-from options similar to GNU tar

@item a CVS exclude mode for ignoring the same files that CVS would ignore

@item can use any transparent remote shell, including rsh or ssh

@item does not require root privileges

@item pipelining of file transfers to minimize latency costs

@item support for anonymous or authenticated rsync servers (ideal for
mirroring)

@end itemize

@menu
* Introductory example::        60-second guide to rsync      
* Local and remote::            Local, remote, and server mode
* Setting up rsync::            
@end menu



@node Introductory example, Local and remote, Overview, Overview
@section Introductory example

Probably the most common case of rsync usage is to copy files to or
from a remote machine using @command{ssh} as a network transport.  In
this situation rsync is a good alternative to @command{scp}.

The most commonly used arguments for rsync are

@table @code

@item -a 
Reproduce the structure and attributes of the origin files as exactly
as possible: this includes copying subdirectories, symlinks, special
files, ownership and permissions.  (@xref{Attributes to copy}.)

@item -v 
Be verbose.  Primarily, display the name of each file as it is copied.

@item -z 
Compress network traffic, using a modified version of the
@command{zlib} library.

@item -P
Display a progress indicator while files are transferred.  This should
normally be ommitted if rsync is not run on a terminal.

@end table

To make a backup of your home directory to the @file{/bkup/mbp/}
remote machine @file{foo.example.org}, preserving the directory
structure, use this command:

@example
rsync -avP ~ foo.example.org:/bkup/mbp/
@end example



@node Local and remote, Setting up rsync, Introductory example, Overview
@comment  node-name,  next,  previous,  up
@section Local and remote

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

@enumerate

@item for copying local files. This is invoked when neither
source nor destination path contains a @code{:} separator

@item for copying from the local machine to a remote machine using
a remote shell program as the transport (such as rsh or
ssh). This is invoked when the destination path contains a
single @code{:} separator.

@item for copying from a remote machine to the local machine
using a remote shell program. This is invoked when the source
contains a @code{:} separator.

@item for copying from a remote rsync server to the local
machine. This is invoked when the source path contains a @code{::}
separator or a @code{rsync://} URL.

@item for copying from the local machine to a remote rsync
server. This is invoked when the destination path contains a @code{::}
separator.

@item for listing files on a remote machine. This is done the
same way as rsync transfers except that you leave off the
local destination.  
@cindex listing files
@end enumerate

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

Any one invocation of rsync makes a copy in a single direction.  rsync
currently has no equivalent of @command{ftp}'s interactive mode.

@cindex @sc{nfs}
@cindex network filesystems
@cindex remote filesystems

rsync's network protocol is generally faster at copying files than
network filesystems such as @sc{nfs} or @sc{cifs}.  It is better to
run rsync on the file server either as a daemon or over ssh than
running rsync giving the network directory.


@node Setting up rsync,  , Local and remote, Overview
@comment  node-name,  next,  previous,  up
@section Setting up rsync

@cindex installation
See the file @sc{install} that comes with the distribution for installation
instructions.

@cindex @command{rsh}
@cindex @command{rsh}, alternatives to
@cindex @command{ssh} 

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

You can also specify an alternative to rsh, either by using the
@option{-e} command line option, or by setting the
@var{@sc{rsync_rsh}} environment variable.

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

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



@node Invoking rsync, Daemon mode, Overview, Top
@comment  node-name,  next,  previous,  up
@chapter Invoking rsync


@menu
* Controlling rsync messages::  
* Attributes to copy::          
* Exit values::                 
@end menu



@node  Controlling rsync messages, Attributes to copy, Invoking rsync, Invoking rsync
@comment  node-name,  next,  previous,  up
@section Controlling rsync messages

@table @option

@item --version
@vindex --version
Print the rsync version number and compilation information and exit

@item --help
@vindex --help
Print a short help page describing the options available and exit.

@item --stats
@vindex --stats
Print statistics about rsync perfomance.

@item -v
@itemx --verbose
@vindex -v
@vindex --verbose
This option increases the amount of information you are given during
the transfer.  By default, rsync works silently.  A single -v will
give you information about what files are being transferred and a
brief summary at the end.  Two -v flags will give you information on
network connections, files skipped, and slightly more information at
the end.  More than two -v flags should only be used if you are
debugging rsync.
@end table


@node Attributes to copy, Exit values, Controlling rsync messages, Invoking rsync
@comment  node-name,  next,  previous,  up
@section Attributes to copy

@table @option

@item -a
@vindex -a
@vindex --archive
@cindex archive mode

Preserve as much as possible of the structure and attributes of the
origin directory.

On many systems, only the superuser can set the ownership of files,
and users can only put files into a group to which that user belongs.
rsync works within the operating system security model.  So on such a
system, if you copy a file which you can read but that does not belong
to you, the destination file will be owned by you.  The only way to
change this behaviour is to copy the file as the superuser, or to
adjust your operating system's security model if that is possible.

@quotation
@strong{Please note:} @option{--archive} does not detect files with
multiple names.  If any exist, they will become multiple identical
files on the destination.  To make the names all refer to the same
file, use @option{--hard-links}.
@end quotation     

@end table



@node  Exit values,  , Attributes to copy, Invoking rsync
@comment  node-name,  next,  previous,  up
@section Exit values

@cindex exit code
@cindex return code

rsync's exit code may be examined by shell scripts to determine
whether the transfer completed successfully or not.

@table @code

@item RERR_SYNTAX     1
Syntax or usage error 

@item RERR_PROTOCOL   2
Protocol incompatibility 

@item RERR_FILESELECT 3
Errors selecting input/output files, dirs

@item RERR_UNSUPPORTED 4
Requested action not supported: an attempt
was made to manipulate 64-bit files on a platform that cannot support
them; or an option was speciifed that is supported by the client and
not by the server.

@item RERR_SOCKETIO   10
Error in socket IO 

@item RERR_FILEIO     11
Error in file IO 

@item RERR_STREAMIO   12
Error in rsync protocol data stream 

@item RERR_MESSAGEIO  13
Errors with program diagnostics 

@item RERR_IPC        14
Error in @sc{ipc} code 

@item RERR_SIGNAL     20
Received @sc{sigusr1} or @sc{sigint}

@item RERR_WAITCHILD  21
Some error returned by @code{waitpid()}

@item RERR_MALLOC     22
Error allocating core memory buffers 

@item RERR_TIMEOUT    30
Timeout in data send/receive 

@end table



@node Daemon mode, Concept Index, Invoking rsync, Top
@chapter Daemon mode

@cindex daemon mode
@cindex demon mode
@cindex @command{rsyncd}
@vindex --daemon

Configuring rsync as a server is entirely optional.  If you just want
to copy your own files between local directories or machines, then
using rsync over @command{ssh} may well be sufficient.  Daemon mode
may be useful if you wish to distribute files to a number of machines
on a network, or to the public.

@vindex --port
@cindex port 873
@cindex @sc{tcp} port 873

@sc{Tcp} port 873 is reserved for rsync by the Internet Assigned
Numbers Authority (@sc{iana}) and has the service name @code{rsync}.
However, rsync may be run on any other port using the @option{--port}
option.

@menu
* Daemon mode security::        
@end menu

@node  Daemon mode security,  , Daemon mode, Daemon mode
@section Daemon mode security

@node     Concept Index, Option Index, Daemon mode, Top
@comment      node-name, next,       previous, up
@unnumbered Concept Index

@printindex cp



@node  Option Index,  , Concept Index, Top
@comment  node-name,  next,  previous,  up
@unnumbered Option Index

@printindex vr

@bye