rsync.sgml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351
  1. <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook V4.1//EN">
  2. <book id="rsync">
  3. <bookinfo>
  4. <title>rsync</title>
  5. <copyright>
  6. <year>1996 -- 2002</year>
  7. <holder>Martin Pool</holder>
  8. <holder>Andrew Tridgell</holder>
  9. </copyright>
  10. <author>
  11. <firstname>Martin</firstname>
  12. <surname>Pool</surname>
  13. </author>
  14. </bookinfo>
  15. <chapter>
  16. <title>Introduction</title>
  17. <para>rsync is a flexible program for efficiently copying files or
  18. directory trees.
  19. <para>rsync has many options to select which files will be copied
  20. and how they are to be transferred. It may be used as an
  21. alternative to ftp, http, scp or rcp.
  22. <para>The rsync remote-update protocol allows rsync to transfer just
  23. the differences between two sets of files across the network link,
  24. using an efficient checksum-search algorithm described in the
  25. technical report that accompanies this package.</para>
  26. <para>Some of the additional features of rsync are:</para>
  27. <itemizedlist>
  28. <listitem>
  29. <para>support for copying links, devices, owners, groups and
  30. permissions
  31. </para>
  32. </listitem>
  33. <listitem>
  34. <para>
  35. exclude and exclude-from options similar to GNU tar
  36. </para>
  37. </listitem>
  38. <listitem>
  39. <para>
  40. a CVS exclude mode for ignoring the same files that CVS would ignore
  41. </listitem>
  42. <listitem>
  43. <para>
  44. can use any transparent remote shell, including rsh or ssh
  45. </listitem>
  46. <listitem>
  47. <para>
  48. does not require root privileges
  49. </listitem>
  50. <listitem>
  51. <para>
  52. pipelining of file transfers to minimize latency costs
  53. </listitem>
  54. <listitem>
  55. <para>
  56. support for anonymous or authenticated rsync servers (ideal for
  57. mirroring)
  58. </para>
  59. </listitem>
  60. </itemizedlist>
  61. </chapter>
  62. <chapter>
  63. <title>Using rsync</title>
  64. <section>
  65. <title>
  66. Introductory example
  67. </title>
  68. <para>
  69. Probably the most common case of rsync usage is to copy files
  70. to or from a remote machine using
  71. <application>ssh</application> as a network transport. In
  72. this situation rsync is a good alternative to
  73. <application>scp</application>.
  74. </para>
  75. <para>
  76. The most commonly used arguments for rsync are
  77. </para>
  78. <variablelist>
  79. <varlistentry>
  80. <term><option>-v</option></term>
  81. <listitem>
  82. <para>Be verbose. Primarily, display the name of each file as it is copied.</para>
  83. </listitem>
  84. </varlistentry>
  85. <varlistentry>
  86. <term><option>-a</option></term>
  87. <listitem>
  88. <para>
  89. Reproduce the structure and attributes of the origin files as exactly
  90. as possible: this includes copying subdirectories, symlinks, special
  91. files, ownership and permissions. (@xref{Attributes to
  92. copy}.)
  93. </para>
  94. </listitem>
  95. </varlistentry>
  96. </variablelist>
  97. <para><option>-v </option>
  98. <para><option>-z</option>
  99. Compress network traffic, using a modified version of the
  100. @command{zlib} library.</para>
  101. <para><option>-P</option>
  102. Display a progress indicator while files are transferred. This should
  103. normally be ommitted if rsync is not run on a terminal.
  104. </para>
  105. </section>
  106. <section>
  107. <title>Local and remote</title>
  108. <para>There are six different ways of using rsync. They
  109. are:</para>
  110. <!-- one of (CALLOUTLIST GLOSSLIST ITEMIZEDLIST ORDEREDLIST SEGMENTEDLIST SIMPLELIST VARIABLELIST CAUTION IMPORTANT NOTE TIP WARNING LITERALLAYOUT PROGRAMLISTING PROGRAMLISTINGCO SCREEN SCREENCO SCREENSHOT SYNOPSIS CMDSYNOPSIS FUNCSYNOPSIS CLASSSYNOPSIS FIELDSYNOPSIS CONSTRUCTORSYNOPSIS DESTRUCTORSYNOPSIS METHODSYNOPSIS FORMALPARA PARA SIMPARA ADDRESS BLOCKQUOTE GRAPHIC GRAPHICCO MEDIAOBJECT MEDIAOBJECTCO INFORMALEQUATION INFORMALEXAMPLE INFORMALFIGURE INFORMALTABLE EQUATION EXAMPLE FIGURE TABLE MSGSET PROCEDURE SIDEBAR QANDASET ANCHOR BRIDGEHEAD REMARK HIGHLIGHTS ABSTRACT AUTHORBLURB EPIGRAPH INDEXTERM REFENTRY SECTION) -->
  111. <orderedlist>
  112. <listitem>
  113. <para>
  114. for copying local files. This is invoked when neither
  115. source nor destination path contains a @code{:} separator
  116. <listitem>
  117. <para>
  118. for copying from the local machine to a remote machine using
  119. a remote shell program as the transport (such as rsh or
  120. ssh). This is invoked when the destination path contains a
  121. single @code{:} separator.
  122. <listitem>
  123. <para>
  124. for copying from a remote machine to the local machine
  125. using a remote shell program. This is invoked when the source
  126. contains a @code{:} separator.
  127. <listitem>
  128. <para>
  129. for copying from a remote rsync server to the local
  130. machine. This is invoked when the source path contains a @code{::}
  131. separator or a @code{rsync://} URL.
  132. <listitem>
  133. <para>
  134. for copying from the local machine to a remote rsync
  135. server. This is invoked when the destination path contains a @code{::}
  136. separator.
  137. <listitem>
  138. <para>
  139. for listing files on a remote machine. This is done the
  140. same way as rsync transfers except that you leave off the
  141. local destination.
  142. </listitem>
  143. </orderedlist>
  144. <para>
  145. Note that in all cases (other than listing) at least one of the source
  146. and destination paths must be local.
  147. <para>
  148. Any one invocation of rsync makes a copy in a single direction. rsync
  149. currently has no equivalent of @command{ftp}'s interactive mode.
  150. @cindex @sc{nfs}
  151. @cindex network filesystems
  152. @cindex remote filesystems
  153. <para>
  154. rsync's network protocol is generally faster at copying files than
  155. network filesystems such as @sc{nfs} or @sc{cifs}. It is better to
  156. run rsync on the file server either as a daemon or over ssh than
  157. running rsync giving the network directory.
  158. </para>
  159. </section>
  160. </chapter>
  161. <chapter>
  162. <title>Frequently asked questions</title>
  163. <!-- one of (CALLOUTLIST GLOSSLIST ITEMIZEDLIST ORDEREDLIST SEGMENTEDLIST SIMPLELIST VARIABLELIST CAUTION IMPORTANT NOTE TIP WARNING LITERALLAYOUT PROGRAMLISTING PROGRAMLISTINGCO SCREEN SCREENCO SCREENSHOT SYNOPSIS CMDSYNOPSIS FUNCSYNOPSIS CLASSSYNOPSIS FIELDSYNOPSIS CONSTRUCTORSYNOPSIS DESTRUCTORSYNOPSIS METHODSYNOPSIS FORMALPARA PARA SIMPARA ADDRESS BLOCKQUOTE GRAPHIC GRAPHICCO MEDIAOBJECT MEDIAOBJECTCO INFORMALEQUATION INFORMALEXAMPLE INFORMALFIGURE INFORMALTABLE EQUATION EXAMPLE FIGURE TABLE MSGSET PROCEDURE SIDEBAR QANDASET ANCHOR BRIDGEHEAD REMARK HIGHLIGHTS ABSTRACT AUTHORBLURB EPIGRAPH INDEXTERM SECTION SIMPLESECT REFENTRY SECT1) -->
  164. <qandaset>
  165. <!-- one of (QANDADIV QANDAENTRY) -->
  166. <qandaentry>
  167. <question>
  168. <!-- one of (CALLOUTLIST GLOSSLIST ITEMIZEDLIST ORDEREDLIST
  169. SEGMENTEDLIST SIMPLELIST VARIABLELIST CAUTION IMPORTANT NOTE
  170. TIP WARNING LITERALLAYOUT PROGRAMLISTING PROGRAMLISTINGCO
  171. SCREEN SCREENCO SCREENSHOT SYNOPSIS CMDSYNOPSIS FUNCSYNOPSIS
  172. CLASSSYNOPSIS FIELDSYNOPSIS CONSTRUCTORSYNOPSIS
  173. DESTRUCTORSYNOPSIS METHODSYNOPSIS FORMALPARA PARA SIMPARA
  174. ADDRESS BLOCKQUOTE GRAPHIC GRAPHICCO MEDIAOBJECT
  175. MEDIAOBJECTCO INFORMALEQUATION INFORMALEXAMPLE
  176. INFORMALFIGURE INFORMALTABLE EQUATION EXAMPLE FIGURE TABLE
  177. PROCEDURE ANCHOR BRIDGEHEAD REMARK HIGHLIGHTS INDEXTERM) -->
  178. <para>Are there mailing lists for rsync?
  179. </question>
  180. <answer>
  181. <para>Yes, and you can subscribe and unsubscribe through a
  182. web interface at
  183. <ulink
  184. url="http://lists.samba.org/">http://lists.samba.org/</ulink>
  185. </para>
  186. <para>
  187. If you are having trouble with the mailing list, please
  188. send mail to the administrator
  189. <email>rsync-admin@lists.samba.org</email>
  190. not to the list itself.
  191. </para>
  192. <para>
  193. The mailing list archives are searchable. Use
  194. <ulink url="http://google.com/">Google</ulink> and prepend
  195. the search with <userinput>site:lists.samba.org
  196. rsync</userinput>, plus relevant keywords.
  197. </para>
  198. </answer>
  199. </qandaentry>
  200. <qandaentry>
  201. <question>
  202. <para>
  203. Why is rsync so much bigger when I build it with
  204. <command>gcc</command>?
  205. </para>
  206. </question>
  207. <answer>
  208. <para>
  209. On gcc, rsync builds by default with debug symbols
  210. included. If you strip both executables, they should end
  211. up about the same size. (Use <command>make
  212. install-strip</command>.)
  213. </para>
  214. </answer>
  215. </qandaentry>
  216. <qandaentry>
  217. <question>
  218. <para>Is rsync useful for a single large file like an ISO image?</para>
  219. </question>
  220. <answer>
  221. <para>
  222. Yes, but note the following:
  223. <para>
  224. Background: A common use of rsync is to update a file (or set of files) in one location from a more
  225. correct or up-to-date copy in another location, taking advantage of portions of the files that are
  226. identical to speed up the process. (Note that rsync will transfer a file in its entirety if no copy
  227. exists at the destination.)
  228. <para>
  229. (This discussion is written in terms of updating a local copy of a file from a correct file in a
  230. remote location, although rsync can work in either direction.)
  231. <para>
  232. The file to be updated (the local file) must be in a destination directory that has enough space for
  233. two copies of the file. (In addition, keep an extra copy of the file to be updated in a different
  234. location for safety -- see the discussion (below) about rsync's behavior when the rsync process is
  235. interrupted before completion.)
  236. <para>
  237. The local file must have the same name as the remote file being sync'd to (I think?). If you are
  238. trying to upgrade an iso from, for example, beta1 to beta2, rename the local file to the same name
  239. as the beta2 file. *(This is a useful thing to do -- only the changed portions will be
  240. transmitted.)*
  241. <para>
  242. The extra copy of the local file kept in a different location is because of rsync's behavior if
  243. interrupted before completion:
  244. <para>
  245. * If you specify the --partial option and rsync is interrupted, rsync will save the partially
  246. rsync'd file and throw away the original local copy. (The partially rsync'd file is correct but
  247. truncated.) If rsync is restarted, it will not have a local copy of the file to check for duplicate
  248. blocks beyond the section of the file that has already been rsync'd, thus the remainder of the rsync
  249. process will be a "pure transfer" of the file rather than taking advantage of the rsync algorithm.
  250. <para>
  251. * If you don't specify the --partial option and rsync is interrupted, rsync will throw away the
  252. partially rsync'd file, and, when rsync is restarted starts the rsync process over from the
  253. beginning.
  254. <para>
  255. Which of these is most desirable depends on the degree of commonality between the local and remote
  256. copies of the file *and how much progress was made before the interruption*.
  257. <para>
  258. The ideal approach after an interruption would be to create a new file by taking the original file
  259. and deleting a portion equal in size to the portion already rsync'd and then appending *the
  260. remaining* portion to the portion of the file that has already been rsync'd. (There has been some
  261. discussion about creating an option to do this automatically.)
  262. The --compare-dest option is useful when transferring multiple files, but is of no benefit in
  263. transferring a single file. (AFAIK)
  264. *Other potentially useful information can be found at:
  265. -[3]http://twiki.org/cgi-bin/view/Wikilearn/RsyncingALargeFile
  266. This answer, formatted with "real" bullets, can be found at:
  267. -[4]http://twiki.org/cgi-bin/view/Wikilearn/RsyncingALargeFileFAQ*
  268. </para>
  269. </answer>
  270. </qandaentry>
  271. </qandaset>
  272. </chapter>
  273. <appendix>
  274. <title>Other Resources</title>
  275. <para><ulink url="http://www.ccp14.ac.uk/ccp14admin/rsync/"></ulink></para>
  276. </appendix>
  277. </book>