Tweak the link colors back to the default.
[rsync-web.git] / FAQ.html
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
2 <HTML>
3 <HEAD>
4 <TITLE>rsync FAQ</TITLE>
5 </HEAD>
6 <!--#include virtual="header.html" -->
7
8 <H2 align="center">Frequently Asked Questions</H2>
9
10 <table><tr valign=top><td><ul>
11 <li><a href="#1">the transfer fails to finish</a><br>
12 <li><a href="#2">rsync recopies the same files</a><br>
13 <li><a href="#3">is your shell clean</a><br>
14 <li><a href="#4">memory usage</a><br>
15 <li><a href="#5">out of memory</a><br>
16 <li><a href="#6">rsync through a firewall</a><br>
17 </ul></td><td>&nbsp;&nbsp;&nbsp;&nbsp;</td><td><ul>
18 <li><a href="#7">rsync and cron</a><br>
19 <li><a href="#8">rsync: Command not found</a><br>
20 <li><a href="#9">spaces in filenames</a><br>
21 <li><a href="#10">ignore "vanished files" warning</a><br>
22 <li><a href="#11">read-only file system</a><br>
23 </ul></td></tr></table>
24
25 <hr>
26 <h3><a name=1>the transfer fails to finish</a></h3>
27
28 <p>If you get an error like one of these:
29
30 <pre>rsync: error writing 4 unbuffered bytes - exiting: Broken pipe
31 rsync error: error in rsync protocol data stream (code 12) at io.c(463)
32 </pre>
33
34 <p>or
35
36 <pre>rsync: connection unexpectedly closed (24 bytes read so far)
37 rsync error: error in rsync protocol data stream (code 12) at io.c(342)
38 </pre>
39
40 <p>please read the <a href="issues.html">issues and debugging page</a>
41 for details on how you can try to figure out what is going wrong.
42
43 <hr>
44 <h3><a name=2>rsync recopies the same files</a></h3>
45
46 <p>Some people occasionally report that rsync copies too many files when
47 they expect it to copy only a few. In most cases the explanation is
48 that you forgot to include the --times (-t) option in the original copy,
49 so rsync is forced to (efficiently) transfer every file that differs in
50 its modified time to discover what data (if any) has changed.
51
52 <p>Another common cause involves sending files to an Microsoft filesystem:
53 if the file's modified time is an odd value but the receiving filesystem
54 can only store even values, then rsync will re-transfer too many files.
55 You can avoid this by specifying the --modify-window=1 option.
56
57 <p>Yet another periodic case can happen when daylight-savings time
58 changes if your OS+filesystem saves file times in local time instead of
59 UTC.  For a full explanation of this and some suggestions on how to
60 avoid them problem, see <a href="daylight-savings.html">this document</a>.
61
62 <p>Something else that can trip up rsync is a filesystem changeing the
63 filename behind the scenes.  This can happen when a filesystem changes
64 an all-uppercase name into lowercase, or when it decomposes UTF-8 behind
65 your back.
66
67 <blockquote>
68
69 <p>An example of the latter can occur with HFS+ on Mac OS X:  if you
70 copy a directory with a file that has a UTF-8 character sequence in it,
71 say a 2-byte umlaut-u (\0303\0274), the file will get that character
72 stored by the filesystem using 3 bytes (\0165\0314\0210), and rsync will
73 not know that these differing filenames are the same file (it will, in
74 fact, remove a prior copy of the file if --delete is enabled, and then
75 recreate it).
76
77 <p>You can avoid a charset problem by passing an appropriate --iconv
78 option to rsync that tells it what character-set the source files are,
79 and what character-set the destination files get stored in.  For
80 instance, the above Mac OS X problem would be dealt with by using
81 --iconv=UTF-8,UTF8-MAC (UTF8-MAC is a pseudo-charset recognized by Mac
82 OS X iconv in which all characters are decomposed).
83
84 </blockquote>
85
86 <p>If you think that rsync is copying too many files, look at the
87 itemized output (-i) to see why rsync is doing the update (e.g. the 't'
88 flag indicates that the time differs, or all pluses indicates that rsync
89 thinks the file doesn't exist).  You can also look at the stats produced
90 with -v and see if rsync is really sending all the data.  See also the
91 --checksum (-c) option for one way to avoid the extra copying of files
92 that don't have synchronized modified times (but keep in mind that the
93 -c option eats lots of disk I/O, and can be rather slow).
94
95 <hr>
96 <h3><a name=3>is your shell clean</a></h3>
97
98 <p>The "is your shell clean" message and the "protocol mismatch" message
99 are usually caused by having some sort of program in your .cshrc, .profile,
100 .bashrc or equivalent file that writes a message every time you connect
101 using a remote-shell program (such as ssh or rsh).  Data written in this
102 way corrupts the rsync data stream. rsync detects this at startup and
103 produces those error messages.  However, if you are using rsync-daemon
104 syntax (host::path or rsync://) without using a remote-shell program (no
105 --rsh or -e option), there is not remote-shell program involved, and the
106 problem is probably caused by an error on the daemon side (so check the
107 daemon logs).
108
109 <p>A good way to test if your remote-shell connection is clean is to try
110 something like this (use ssh or rsh, as appropriate):
111
112 <blockquote><pre>ssh remotesystem /bin/true &gt; test.dat</pre></blockquote>
113
114 <p>That should create a file called test.dat with nothing in it. If
115 test.dat is not of zero length then your shell is not clean.  Look at the
116 contents of test.dat to see what was sent. Look at all the startup files on
117 remotesystem to try and find the problem.
118
119 <hr>
120 <h3><a name=4>memory usage</a></h3>
121
122 <p>Rsync versions before 3.0.0 always build the entire list of files to be
123 transferred at the beginning and hold it in memory for the entire run.  Rsync
124 needs about 100 bytes to store all the relevant information for one file,
125 so (for example) a run with 800,000 files would consume about 80M of
126 memory.  -H and --delete increase the memory usage further.
127
128 <p>Version 3.0.0 slightly reduced the memory used per file by not storing fields
129 not needed for a particular file.  It also introduced an incremental recursion
130 mode that builds the file list in chunks and holds each chunk in memory only as
131 long as it is needed.  This mode dramatically reduces memory usage, but it
132 only works provided that both sides are 3.0.0 or newer and certain options that
133 rsync currently can't handle in this mode are not being used.
134
135 <hr>
136 <h3><a name=5>out of memory</a></h3>
137
138 <p>The usual reason for "out of memory" when running rsync is that you are
139 transferring a _very_ large number of files.  The size of the files doesn't
140 matter, only the total number of files.  If memory is a problem, first try to
141 use the incremental recursion mode: upgrade both sides to rsync 3.0.0 or
142 newer and avoid options that disable incremental recursion (e.g., use
143 <tt>--delete-delay</tt> instead of <tt>--delete-after</tt>).  If this is not
144 possible, you can break the rsync run into smaller chunks operating on
145 individual subdirectories using <tt>--relative</tt> and/or exclude rules.
146
147 <hr>
148 <h3><a name=6>rsync through a firewall</a></h3>
149
150 <p>If you have a setup where there is no way to directly connect two
151 systems for an rsync transfer, there are several ways to get a firewall
152 system to act as an intermediary in the transfer.  You'll find full details
153 on the <a href="firewall.html">firewall methods</a> page.
154
155 <hr>
156 <h3><a name=7>rsync and cron</a></h3>
157
158 <p>On some systems (notably SunOS4) cron supplies what looks like a socket
159 to rsync, so rsync thinks that stdin is a socket. This means that if you
160 start rsync with the --daemon switch from a cron job you end up rsync
161 thinking it has been started from inetd. The fix is simple&mdash;just
162 redirect stdin from /dev/null in your cron job.
163
164 <hr>
165 <h3><a name=8>rsync: Command not found</a></h3>
166
167 <p>This error is produced when the remote shell is unable to locate the rsync
168 binary in your path. There are 3 possible solutions:
169
170 <ol>
171
172 <li>install rsync in a "standard" location that is in your remote path. 
173
174 <li>modify your .cshrc, .bashrc etc on the remote system to include the path
175 that rsync is in
176
177 <li>use the --rsync-path option to explicitly specify the path on the
178 remote system where rsync is installed
179
180 </ol>
181
182 <p>You may echo find the command:
183
184 <blockquote><pre>ssh host 'echo $PATH'</pre></blockquote>
185
186 <p>for determining what your remote path is.
187
188 <hr>
189 <h3><a name=9>spaces in filenames</a></h3>
190
191 <p>Can rsync copy files with spaces in them?
192
193 <p>Short answer: Yes, rsync can handle filenames with spaces.
194
195 <p>Long answer: 
196
197 <p>Rsync handles spaces just like any other unix command line application.
198 Within the code spaces are treated just like any other character so a
199 filename with a space is no different from a filename with any other
200 character in it.
201
202 <p>The problem of spaces is in the argv processing done to interpret the
203 command line.  As with any other unix application you have to escape spaces
204 in some way on the command line or they will be used to separate arguments. 
205
206 <p>It is slightly trickier in rsync (and other remote-copy programs like
207 scp) because rsync sends a command line to the remote system to launch the
208 peer copy of rsync (this assumes that we're not talking about daemon mode,
209 which is not affected by this problem because no remote shell is involved
210 in the reception of the filenames).  The command line is interpreted by the
211 remote shell and thus the spaces need to arrive on the remote system
212 escaped so that the shell doesn't split such filenames into multiple
213 arguments.
214
215 <p>For example:
216
217 <blockquote><pre>rsync -av host:'a long filename' /tmp/</pre></blockquote>
218
219 <p>This is usually a request for rsync to copy 3 files from the remote
220 system, "a", "long", and "filename" (the only exception to this is for a
221 system running a shell that does not word-split arguments in its commands,
222 and that is exceedingly rare).  If you wanted to request a single file with
223 spaces, you need to get some kind of space-quoting characters to the remote
224 shell that is running the remote rsync command.  The following commands
225 should all work:
226
227 <blockquote><pre>rsync -av host:'"a long filename"' /tmp/
228 rsync -av host:'a\ long\ filename' /tmp/
229 rsync -av host:a\\\ long\\\ filename /tmp/</pre></blockquote>
230
231 <p>You might also like to use a '?' in place of a space as long as there
232 are no other matching filenames than the one with spaces (since '?' matches
233 any character):
234
235 <blockquote><pre>rsync -av host:a?long?filename /tmp/</pre></blockquote>
236
237 <p>As long as you know that the remote filenames on the command line
238 are interpreted by the remote shell then it all works fine. 
239
240 <hr>
241 <h3><a name=10>ignore "vanished files" warning</a></h3>
242
243 <p>Some folks would like to ignore the "vanished files" warning, which
244 manifests as an exit-code 24.  The easiest way to do this is to create
245 a shell script wrapper.  For instance, name this something like
246 "rsync-no24":
247
248 <blockquote><pre>#!/bin/sh
249 rsync "$@"
250 e=$?
251 if test $e = 24; then
252     exit 0
253 fi
254 exit $e</pre></blockquote>
255
256 <hr>
257 <h3><a name=11>read-only file system</a></h3>
258
259 <p>If you get "Read-only file system" as an error when sending to a rsync
260 daemon then you probably forgot to set "read only = no" for that module.
261
262 <hr>
263
264
265
266 <!--#include virtual="footer.html" -->