unison-manual.tex (106109B)
1 \documentclass{article} 2 \usepackage{alltt} 3 \usepackage{fullpage} 4 \usepackage{moreverb} 5 % \usepackage{hyperref} 6 \usepackage{hevea} 7 \ifhevea\@def@charset{UTF-8}\fi 8 9 \input{local} 10 \fulltrue 11 12 %\newcommand{\NT}[1]{\(\langle\)\textit{#1}\(\rangle\)} 13 \newcommand{\NT}[1]{\textit{#1}} 14 \newcommand{\ARG}[1]{\texttt{\textit{#1}}} 15 16 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 17 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 18 \begin{document} 19 20 \ifhevea\begin{rawhtml}<div id="manualbody">\end{rawhtml}\fi 21 22 \ifhevea\else\bigskip\fi% 23 \ifdraft% 24 \begin{center}% 25 {\Huge \ifhevea\red\fi DraftDraftDraftDraft}% 26 \end{center}% 27 \ifhevea\else \bigskip \fi 28 \fi 29 30 \ifhevea\begin{rawhtml}<div id="manualheader">\end{rawhtml}% 31 \else \thispagestyle{empty} 32 \fi% 33 \SNIP{About Unison}{about}% 34 \iftextversion 35 \section*{Unison File Synchronizer 36 %% \\ 37 %% \ONEURL{http://www.cis.upenn.edu/\home{bcpierce}/unison} 38 \\ 39 Version 40 \unisonversion 41 } 42 \else% 43 \ifhevea\else \vspace*{2in} \fi% 44 \begin{center}% 45 \Huge{\ifhevea\black\else\bf \fi Unison File Synchronizer}% 46 %% \ifhevea \\ \else \\[2ex] \fi 47 %% \large 48 %% \ONEURL{http://www.cis.upenn.edu/\home{bcpierce}/unison} 49 \ifhevea \\ \else \\[2ex] \fi% 50 \huge {\ifhevea\black\else\bf \fi User Manual and Reference Guide}% 51 \ifhevea \\ \else \\[6ex] \fi% 52 \LARGE% 53 Version \unisonversion \\[4ex] % 54 % \today % 55 \large Copyright 1998-2023, Benjamin C. Pierce 56 \end{center}% 57 \fi% 58 % 59 % 60 \ifhevea\begin{rawhtml}</div>\end{rawhtml}\fi 61 62 \ifhevea\else\newpage\fi 63 \TABLEOFCONTENTS 64 \ifhevea\else\newpage\fi 65 66 \SECTION{Overview}{overview}{ } 67 68 \input{short} 69 70 \ifhevea\else\bigskip\fi 71 72 % \begin{quote} 73 % {\bf\ifhevea\red\fi Warning:} The current implementation of Unison is 74 % considered beta-test software. It is in daily use by quite a few 75 % people, but there are still undoubtedly some bugs. If you choose to 76 % use it to synchronize important data, please pay careful attention 77 % to what it is doing! Also, the installation/setup procedure is not 78 % yet as smooth as we want it to be. 79 % \end{quote} 80 81 82 \SECTION{Preface}{intro}{ } 83 84 \TOPSUBSECTION{People}{people} 85 86 \URL{http://www.cis.upenn.edu/\home{bcpierce}/}{Benjamin Pierce} leads the 87 Unison project. 88 % 89 The current version of Unison was designed and implemented by 90 \URL{http://www.research.att.com/\home{trevor}/}{Trevor Jim}, 91 \URL{http://www.cis.upenn.edu/\home{bcpierce}/}{Benjamin Pierce}, 92 and 93 \URL{http://www.pps.jussieu.fr/\home{vouillon}/}{J\'{e}r\^{o}me Vouillon}, 94 with 95 \URL{http://alan.petitepomme.net/}{Alan Schmitt}, 96 {Malo Denielou}, 97 \URL{http://www.brics.dk/\home{zheyang}/}{Zhe Yang}, 98 Sylvain Gommier, and 99 Matthieu Goulay. 100 % 101 The Mac user interface was started by Trevor Jim and enormously improved by 102 Ben Willmore. 103 % 104 Our implementation of the 105 \URL{http://samba.org/rsync/}{rsync} 106 protocol was built by 107 \URL{http://www.eecs.harvard.edu/\home{nr}/}{Norman Ramsey} 108 and Sylvain Gommier. It is based on 109 \URL{http://samba.anu.edu.au/\home{tridge}/}{Andrew Tridgell}'s 110 \URL{http://samba.anu.edu.au/\home{tridge}/phd\_thesis.pdf}{thesis work} 111 and inspired by his 112 \URL{http://samba.org/rsync/}{rsync} 113 utility. 114 % \finish{Our low-level fingerprinting implementation uses an algorithm 115 % by Michael Rabin and incorporates some coding tricks from Andrei 116 % Broder and Mike Burrows.} 117 % 118 The mirroring and merging functionality was implemented by 119 Sylvain Roy, improved by Malo Denielou, and improved yet further by 120 St\'ephane Lescuyer. 121 % 122 \URL{http://wwwfun.kurims.kyoto-u.ac.jp/\home{garrigue}/}{Jacques Garrigue} 123 contributed the original Gtk version of the user 124 interface; the Gtk2 version was built by Stephen Tse. 125 % 126 Sundar Balasubramaniam helped build a prototype implementation of 127 an earlier synchronizer in Java. 128 \URL{http://www.cis.upenn.edu/\home{ishin}/}{Insik Shin} 129 and 130 \URL{http://www.cis.upenn.edu/\home{lee}/}{Insup Lee} contributed design 131 ideas to this implementation. 132 \URL{http://research.microsoft.com/\home{fournet}/}{Cedric Fournet} 133 contributed to an even earlier prototype. 134 135 \TOPSUBSECTION{Obtaining Unison}{obtaining} 136 137 \paragraph{Source code} 138 139 Unison is primarily distributed as source code, which contains 140 instructions in {\tt INSTALL.md}: 141 \begin{quote} 142 \ONEURL{https://github.com/bcpierce00/unison} 143 \end{quote} 144 145 \paragraph{Binaries} 146 147 The Unison wiki contains information about builds done as part of 148 Continuous Integration and other sources of binaries; read the entire 149 wiki at: 150 \begin{quote} 151 \ONEURL{https://github.com/bcpierce00/unison/wiki} 152 \end{quote} 153 154 \TOPSUBSECTION{Community, Maintenance, and Development}{development} 155 156 Many people use and contribute to Unison. 157 This community has two main homes. 158 159 \paragraph{Mailinglists} 160 161 Most discussion is appropriate on one of the mailinglists: 162 \begin{quote} 163 \ONEURL{https://github.com/bcpierce00/unison/wiki/Mailing-Lists} 164 \end{quote} 165 166 \paragraph{Reporting Bugs} 167 168 Bug reports and feature requests may be made after reading the guidelines: 169 \begin{quote} 170 \ONEURL{https://github.com/bcpierce00/unison/wiki/Reporting-Bugs-and-Feature-Requests} 171 \end{quote} 172 173 Help improving Unison is welcome; see {\tt CONTRIBUTING.md} in the sources. 174 175 \TOPSUBSECTION{Copying}{copying} 176 177 This file is part of Unison. 178 179 Unison is free software: you can redistribute it and/or modify 180 it under the terms of the GNU General Public License as published by 181 the Free Software Foundation, either version 3 of the License, or 182 (at your option) any later version. 183 184 Unison is distributed in the hope that it will be useful, 185 but WITHOUT ANY WARRANTY; without even the implied warranty of 186 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 187 GNU General Public License for more details. 188 189 The GNU General Public License can be found at 190 \ONEURL{http://www.gnu.org/licenses}. A copy is also included in the 191 Unison source distribution in the file {\tt COPYING}. 192 193 \TOPSUBSECTION{Acknowledgements}{ack} 194 195 Work on Unison has been supported by the National Science Foundation 196 under grants CCR-9701826 and ITR-0113226, {\em Principles and Practice of 197 Synchronization}, and by University of Pennsylvania's Institute for 198 Research in Cognitive Science (IRCS). 199 200 201 \SECTION{Upgrading}{upgrading}{upgrading} 202 203 (This section is perhaps misplaced, but is early because it is far 204 better to have at least skimmed it than to not know it exists.) 205 206 Before upgrading, it is a good idea to run the {\em old} version one last 207 time, to make sure all your replicas are completely synchronized. A new 208 version of Unison will sometimes introduce a different format for the 209 archive files used to remember information about the previous state of the 210 replicas. In this case, the old archive will be ignored (not deleted --- if 211 you roll back to the previous version of Unison, you will find the old 212 archives intact), which means that any differences between the replicas will 213 show up as conflicts that need to be resolved manually. 214 215 As of version 2.52, Unison has a degree of backward and forward 216 compatibility. This means three things. First, it is possible for local 217 and remote machines to run a different version of Unison. Second, it is 218 possible for local and remote machines to run a version (same or different) 219 of Unison built with a different version of OCaml compiler (this has been 220 problematic historically). Lastly, it is possible to upgrade Unison on 221 the local machine (compiled with any OCaml version) and keep the existing 222 archive. 223 224 If version interoperability requirements are followed then Unison 2.52 and 225 newer can upgrade the archive created by earlier Unison versions. To avoid 226 rebuilding archive files when upgrading from a version older than 2.52, you 227 must install version 2.52 or newer built with the same OCaml version as your 228 previous version of Unison, and then run it at least once on each root. Doing 229 so will upgrade the archive file. 230 231 After upgrading the archive, you are free to swap the Unison 2.52 or newer 232 executable to one compiled with a different version of OCaml. 233 The archive file is no longer dependent on the compiler version. 234 235 \SUBSECTION{Version interoperability}{interoperability} 236 237 To ensure interoperability with different Unison versions on local and 238 remote machines, and to upgrade from an earlier version {\em without 239 rebuilding the archive files}, you have to remember these guidelines. 240 Upgrading from an incompatible version, while possible and normal, will 241 require fully scanning both roots, which can be time-consuming with big 242 replicas. 243 244 {\bf Unison 2.52 and newer} are compatible with: 245 \begin{itemize} 246 \item {\em Unison 2.52 or newer} (for as long as backwards compatibility 247 is maintained in the newer versions). You do not have to pay any attention 248 to OCaml compiler versions. 249 \item {\em Unison 2.51} if both versions are compiled with same OCaml 250 compiler version (you can see which compiler version was used by running 251 {\tt unison -version}). 252 \item {\em Unison 2.48} if both versions are compiled with same OCaml 253 compiler version. See special notes below. 254 \end{itemize} 255 256 \vspace{1em} 257 \noindent {\bf Interoperability matrix} for quick reference: 258 259 \vspace{1em} 260 \begin{tabular}{r||c|c|c} 261 Client versions & \multicolumn{3}{c}{Server versions} \\ 262 & 2.52 or newer & 2.51 & 2.48 \\ 263 \hline \hline 264 2.52 or newer & full interop & same OCaml version & same OCaml version \\ 265 \hline 266 2.51 & same OCaml version & full interop & no interop \\ 267 \hline 268 2.48 & same OCaml version* & no interop & full interop \\ 269 \end{tabular} 270 \vspace{2em} 271 272 \noindent {\it Special notes for Unison 2.48:} 273 \begin{itemize} 274 \item Unison 2.48 does not show which OCaml compiler was used to compile it. 275 If you do not have the option of re-compiling the 2.48 version, you have 276 two alternatives. First (and most likely to succeed), see what is the version 277 of the OCaml compiler in the same package repository where you installed 278 Unison 2.48 from, then use Unison 2.52 compiled with that version. 279 Second, you can just try Unison 2.52 executables compiled with different 280 OCaml versions and see which one works with your copy of Unison 2.48. 281 \item When running Unison 2.48 on the client machine with Unison 2.52 or 282 newer on the server machine, you have to do some additional configuration. 283 The Unison executable name on the server must start with \verb|unison-2.48| 284 (just \verb|unison-2.48| is ok, as is \verb|unison-2.48.exe|, but also 285 \verb|unison-2.48+ocaml-4.05|). If using TCP socket connection to the 286 server then you're all set! If using {\tt ssh} then you have to add one 287 of the following options to your profile or as a command-line argument 288 on the client machine: \verb|-addversionno|; see 289 \sectionref{remote}{Remote Usage}, or \verb|-servercmd|; see 290 \sectionref{rshmeth}{Remote Shell Method}. 291 \end{itemize} 292 293 294 \SECTION{Tutorial}{tutorial}{tutorial} 295 296 %\finish{Put a pointer somewhere in here to the typical profile in the 297 % reference section.} 298 299 \SUBSECTION{Preliminaries}{prelim} 300 301 Unison can be used with either of two user interfaces: 302 \begin{enumerate} 303 \item a textual interface and 304 \item a graphical interface 305 \end{enumerate} 306 The textual interface is more convenient for running from scripts and 307 works on dumb terminals; the graphical interface is better for most 308 interactive use. For this tutorial, you can use either. If you are running 309 Unison from the command line, just typing {\tt unison} 310 will select either the text or the graphical interface, depending on which 311 has been selected as default when the executable you are running was 312 built. You can force the text interface even if graphical is the default by 313 adding {\tt -ui text}. 314 The other command-line arguments to both versions are identical. 315 316 The graphical version can also be run directly by clicking on its 317 icon. 318 For this tutorial, we assume that you're starting it from the command 319 line. 320 321 Unison can synchronize files and directories on a single machine, or 322 between two machines on a network. (The same program runs on both 323 machines; the only difference is which one is responsible for 324 displaying the user interface.) If you're only interested in a 325 single-machine setup, then let's call that machine the \CLIENT{}. If 326 you're synchronizing two machines, let's call them \CLIENT{} and 327 \SERVER. 328 329 \SUBSECTION{Local Usage}{local} 330 331 Let's get the client machine set up first and see how to synchronize 332 two directories on a single machine. 333 334 Ensure that unison is installed on your system. 335 336 Create a small test directory {\tt a.tmp} containing a couple of files 337 and/or subdirectories, e.g., 338 \begin{verbatim} 339 mkdir a.tmp 340 touch a.tmp/a a.tmp/b 341 mkdir a.tmp/d 342 touch a.tmp/d/f 343 \end{verbatim} 344 Copy this directory to b.tmp: 345 \begin{verbatim} 346 cp -r a.tmp b.tmp 347 \end{verbatim} 348 349 Now try synchronizing {\tt a.tmp} and {\tt b.tmp}. (Since they are 350 identical, synchronizing them won't propagate any changes, but Unison 351 will remember the current state of both directories so that it will be 352 able to tell next time what has changed.) Type: 353 \begin{verbatim} 354 unison a.tmp b.tmp 355 \end{verbatim} 356 (You may need to add \verb|-ui text|, depending how your unison binary was built.) 357 358 \begin{textui} 359 You should see a message notifying you that all the files are actually 360 equal and then get returned to the command line. 361 \end{textui} 362 363 \begin{tkui} 364 You should get a big empty window with a message at the bottom 365 notifying you that all files are identical. Choose the Exit item from 366 the File menu to get back to the command line. 367 \end{tkui} 368 369 Next, make some changes in a.tmp and/or b.tmp. For example: 370 \begin{verbatim} 371 rm a.tmp/a 372 echo "Hello" > a.tmp/b 373 echo "Hello" > b.tmp/b 374 date > b.tmp/c 375 echo "Hi there" > a.tmp/d/h 376 echo "Hello there" > b.tmp/d/h 377 \end{verbatim} 378 Run Unison again: 379 \begin{verbatim} 380 unison a.tmp b.tmp 381 \end{verbatim} 382 383 This time, the user interface will display only the files that have 384 changed. If a file has been modified in just one 385 replica, then it will be displayed with an arrow indicating the 386 direction that the change needs to be propagated. For example, 387 \begin{verbatim} 388 <--- new file c [f] 389 \end{verbatim} 390 \noindent 391 indicates that the file {\tt c} has been modified only in the second 392 replica, and that the default action is therefore to propagate the new 393 version to the first replica. To {\bf f}ollow Unison's recommendation, 394 press the ``f'' at the prompt. 395 396 If both replicas are modified and their contents are different, then 397 the changes are in conflict: \texttt{<-?->} is displayed to indicate 398 that Unison needs guidance on which replica should override the 399 other. 400 \begin{verbatim} 401 new file <-?-> new file d/h [] 402 \end{verbatim} 403 By default, neither version will be propagated and both 404 replicas will remain as they are. 405 406 If both replicas have been modified but their new contents are the same 407 (as with the file {\tt b}), then no propagation is necessary and 408 nothing is shown. Unison simply notes that the file is up to date. 409 410 These display conventions are used by both versions of the user 411 interface. The only difference lies in the way in which Unison's 412 default actions are either accepted or overridden by the user. 413 414 \begin{textui} 415 The status of each modified file is displayed, in turn. 416 When the copies of a file in the two replicas are not identical, the 417 user interface will ask for instructions as to how to propagate the 418 change. If some default action is indicated (by an arrow), you can 419 simply press Return to go on to the next changed file. If you want to 420 do something different with this file, press ``\verb|<|'' or ``\verb|>|'' to force 421 the change to be propagated from right to left or from left to right, 422 or else press ``\verb|/|'' to skip this file and leave both replicas alone. 423 When it reaches the end of the list of modified files, Unison will ask 424 you one more time whether it should proceed with the updates that have 425 been selected. 426 427 When Unison stops to wait for input from the user, pressing ``\verb|?|'' 428 will always give a list of possible responses and their meanings. 429 \end{textui} 430 431 \begin{tkui} 432 The main window shows all the files that have been modified in either 433 {\tt a.tmp} or {\tt b.tmp}. To override a default action (or to select 434 an action in the case when there is no default), first select the file, either 435 by clicking on its name or by using the up- and down-arrow keys. Then 436 press either the left-arrow or ``\verb|<|'' key (to cause the version in b.tmp to 437 propagate to a.tmp) or the right-arrow or ``\verb|>|'' key (which makes the a.tmp 438 version override b.tmp). 439 440 Every keyboard command can also be invoked from the menus at the top 441 of the user interface. (Conversely, each menu item is annotated with 442 its keyboard equivalent, if it has one.) 443 444 When you are satisfied with the directions for the propagation of changes 445 as shown in the main window, click the ``Go'' button to set them in 446 motion. A check sign will be displayed next to each filename 447 when the file has been dealt with. 448 \end{tkui} 449 450 451 \SUBSECTION{Remote Usage}{remote} 452 453 Next, we'll get Unison set up to synchronize replicas on two different 454 machines. 455 456 NB: Unison has not been designed to run with elevated privileges 457 (e.g. setuid), and it has not been audited for that environment. 458 Therefore Unison should be run with the userid of the owner of the 459 files to be synchronized, and should never be run setuid or similar. 460 (Problems encountered when running setuid etc. must be reproduced 461 without setuid before being reported as bugs.) 462 463 Follow the instructions in the Installation section to download or 464 build an executable version of Unison on the server machine, and 465 install it somewhere on your search path. (It doesn't matter whether 466 you install the textual or graphical version, since the copy of Unison on 467 the server doesn't need to display any user interface at all. The major 468 benefit of installing the textual version is that it doesn't have any external 469 dependencies required by the GUI executable.) 470 471 It is important that the version of Unison installed on the server 472 machine is the same as the version of Unison on the client machine. 473 But some flexibility on the version of Unison at the client side can 474 be achieved by using the \verb|-addversionno| option; see 475 \sectionref{prefs}{Preferences}. 476 477 Now there is a decision to be made. Unison provides two methods for 478 communicating between the client and the server: 479 \begin{itemize} 480 \item {\em Remote shell method}: To use this method, you must have 481 some way of invoking remote commands on the server from the client's 482 command line, using a facility such as \verb|ssh|. 483 This method is more convenient (since there is no need to manually 484 start a ``unison server'' process on the server) and also more 485 secure, assuming you are using \verb|ssh|). 486 487 \item {\em TCP socket method}: This method requires only that you can 488 get TCP packets from the client to the server and back. It is 489 insecure and should not be used. 490 491 \item {\em Unix socket method}: This method only works within a 492 single machine. It is similar to the TCP sockets method, but it is 493 possible to configure it securely. 494 \end{itemize} 495 496 Decide which of these you want to try, and continue with 497 \sectionref{rshmeth}{Remote Shell Method} or 498 \sectionref{socketmeth}{Socket Method}, as appropriate. 499 500 501 \SUBSECTION{Remote Shell Method}{rshmeth} 502 503 The standard remote shell facility on Unix systems is \verb|ssh|. 504 505 Running 506 \verb|ssh| requires some coordination between the client and server 507 machines to establish that the client is allowed to invoke commands on 508 the server; please refer to the \verb|ssh| documentation 509 for information on how to set this up. 510 511 First, test that we can invoke Unison on the server from the client. 512 Typing 513 \begin{alltt} 514 ssh \NT{remotehostname} unison -version 515 \end{alltt} 516 should print the same version information as running 517 \begin{verbatim} 518 unison -version 519 \end{verbatim} 520 locally on the client. If remote execution fails, then either 521 something is wrong with your ssh setup (e.g., ``permission denied'') 522 or else the search path that's being used when executing commands on 523 the server doesn't contain the \verb|unison| executable (e.g., 524 ``command not found''). 525 526 Create a test directory {\tt a.tmp} in your home directory on the client 527 machine. 528 529 Test that the local unison client can start and connect to the 530 remote server. Type 531 \begin{alltt} 532 unison -testServer a.tmp ssh://\NT{remotehostname}/a.tmp 533 \end{alltt} 534 535 Now cd to your home directory and type: 536 \begin{verbatim} 537 unison a.tmp ssh://remotehostname/a.tmp 538 \end{verbatim} 539 The result should be that the entire directory {\tt a.tmp} is propagated 540 from the client to your home directory on the server. 541 542 After finishing the first synchronization, change a few files and try 543 synchronizing again. You should see similar results as in the local 544 case. 545 546 If your user name on the server is not the same as on the client, you 547 need to specify it on the command line: 548 \begin{verbatim} 549 unison a.tmp ssh://username@remotehostname/a.tmp 550 \end{verbatim} 551 552 \noindent {\it Notes:} 553 \begin{itemize} 554 \item If you want to put \verb|a.tmp| some place other than your home 555 directory on the remote host, you can give an absolute path for it by 556 adding an extra slash between \verb|remotehostname| and the beginning 557 of the path: 558 \begin{verbatim} 559 unison a.tmp ssh://remotehostname//absolute/path/to/a.tmp 560 \end{verbatim} 561 562 \item You can give an explicit path for the \verb|unison| executable 563 on the server by using the command-line option \showtt{-servercmd 564 /full/path/name/of/unison} or adding 565 \showtt{servercmd=/full/path/name/of/unison} to your profile (see 566 \sectionref{profile}{Profiles}). Similarly, you can specify an 567 explicit path for the \verb|ssh| program using the \showtt{-sshcmd} 568 option. 569 Extra arguments can be passed to \verb|ssh| by setting the 570 \verb|-sshargs| preference. 571 572 \item By leveraging \showtt{-sshcmd} and \showtt{-sshargs}, you can 573 effectively use any remote shell program, not just \verb|ssh|; just 574 remember that the roots are still specified with \verb|ssh| as the 575 protocol, that is, they have to start with \showtt{ssh://}. 576 \end{itemize} 577 578 579 \SUBSECTION{Socket Method}{socketmeth} 580 581 To run Unison over a socket connection, you must start a Unison 582 daemon process on the server. This process runs continuously, 583 waiting for connections over a given socket from client machines 584 running Unison and processing their requests in turn. 585 586 Since the socket method is not used by many people, its functionality is 587 rather limited. For example, the server can only deal with one client at a 588 time. 589 590 Note that the Unison daemon process is always started with a command-line 591 argument; not from a profile. 592 593 \SUBSUBSECTION{TCP Sockets}{socket-tcp} 594 595 \begin{quote} 596 {\bf\ifhevea\red\fi Warning:} The TCP socket method is 597 insecure: not only are the texts of your changes transmitted over 598 the network in unprotected form, it is also possible for anyone in 599 the world to connect to the server process and read out the contents 600 of your filesystem! (Of course, to do this they must understand the 601 protocol that Unison uses to communicate between client and server, 602 but all they need for this is a copy of the Unison sources.) The socket 603 method is provided only for expert users with specific needs; everyone 604 else should use the \verb|ssh| method. 605 \end{quote} 606 607 608 To start the daemon for connections over a TCP socket, type 609 \begin{verbatim} 610 unison -socket NNNN 611 \end{verbatim} 612 on the server machine, where {\tt NNNN} is the TCP port number that the 613 daemon should listen on for connections from clients. ({\tt NNNN} can 614 be any large number that is not being used by some other program; if 615 \texttt{NNNN} is already in use, Unison will exit with an error 616 message.) 617 618 Create a test directory {\tt a.tmp} in your home directory on the 619 client machine. Now type: 620 \begin{alltt} 621 unison a.tmp socket://\NT{remotehostname}:NNNN/a.tmp 622 \end{alltt} 623 Note that paths specified by the client will be interpreted relative 624 to the directory in which you start the server process; this behavior 625 is different from the ssh case, where the path is relative to your home 626 directory on the server. 627 % 628 The result should be that the entire directory {\tt a.tmp} is 629 propagated from the client to the server (\texttt{a.tmp} will be 630 created on the server in the directory that the server was started 631 from). 632 % 633 After finishing the first synchronization, change a few files and try 634 synchronizing again. You should see similar results as in the local 635 case. 636 637 By default Unison will listen for incoming connections on all interfaces. 638 If you want to limit this to certain interfaces or addresses then you 639 can use the {\tt -listen} command-line argument, specifying a host name 640 or an IP address to listen on. {\tt -listen} can be given multiple 641 times to listen on several addresses. 642 643 \SUBSUBSECTION{Unix Domain Sockets}{socket-unix} 644 645 To start the daemon for connections over a Unix domain socket, type 646 \begin{verbatim} 647 unison -socket PPPP 648 \end{verbatim} 649 where {\tt PPPP} is the path to a Unix socket that the daemon should 650 open for connections from clients. ({\tt PPPP} can be any absolute or 651 relative path the server process has access to but it must not exist 652 yet; the socket is created at that path when the daemon process is 653 started.) You are responsible for securing access to the socket path. 654 For example, this can be done by controlling the permissions of 655 socket's parent directory, or ensuring a restrictive {\tt umask} value 656 when starting Unison. 657 658 Clients can connect to a server over a Unix domain socket by specifying 659 the absolute or relative path to the socket, instead of a server address 660 and port number: 661 \begin{alltt} 662 unison a.tmp socket://\{\NT{path/to/unix/socket}\}/a.tmp 663 \end{alltt} 664 (socket path is enclosed in curly braces). 665 666 Note that Unix domain sockets are local sockets (they exist in the 667 filesystem namespace). 668 One could use Unixs socket remotely, by forwarding access to the 669 socket by other means, for example by using {\tt spiped} secure pipe 670 daemon. 671 672 \SUBSECTION{Using Unison for All Your Files}{usingit} 673 674 Once you are comfortable with the basic operation of Unison, you may 675 find yourself wanting to use it regularly to synchronize your commonly 676 used files. There are several possible ways of going about this: 677 678 \begin{enumerate} 679 \item Synchronize your whole home directory, using the Ignore facility 680 (see \sectionref{ignore}{Ignoring Paths}) 681 to avoid synchronizing temporary files and things that only belong on 682 one host. 683 \item Create a subdirectory called {\tt shared} (or {\tt current}, or 684 whatever) in your home directory on each host, and put all the files 685 you want to synchronize into this directory. 686 \item Create a subdirectory called {\tt shared} (or {\tt current}, or 687 whatever) in your home directory on each host, and put {\em links to} 688 all the files you want to synchronize into this directory. Use the 689 {\tt follow} preference (see \sectionref{symlinks}{Symbolic Links}) to make 690 Unison treat these links as transparent. 691 \item Make your home directory the root of the synchronization, but 692 tell Unison to synchronize only some of the files and subdirectories 693 within it on any given run. This can be accomplished by using the {\tt -path} switch 694 on the command line: 695 \begin{alltt} 696 unison /home/\NT{username} ssh://\NT{remotehost}//home/\NT{username} -path shared 697 \end{alltt} 698 The {\tt -path} option can be used as many times as needed, to 699 synchronize several files or subdirectories: 700 \begin{alltt} 701 unison /home/\NT{username} ssh://\NT{remotehost}//home/\NT{username} \verb|\| 702 -path shared \verb|\| 703 -path pub \verb|\| 704 -path .netscape/bookmarks.html 705 \end{alltt} 706 These \verb|-path| arguments can also be put in your preference file. 707 See \sectionref{prefs}{Preferences} for an example. 708 \end{enumerate} 709 710 Most people find that they only need to maintain a profile (or 711 profiles) on one of the hosts that they synchronize, since Unison is 712 always initiated from this host. (For example, if you're 713 synchronizing a laptop with a fileserver, you'll probably always run 714 Unison on the laptop.) This is a bit different from the usual 715 situation with asymmetric mirroring programs like \verb|rdist|, where 716 the mirroring operation typically needs to be initiated from the 717 machine with the most recent changes. \sectionref{profile}{Profiles} 718 covers the syntax of Unison profiles, together with some sample profiles. 719 720 \SUBSECTION{Using Unison to Synchronize More Than Two Machines}{usingmultiple} 721 722 Unison is designed for synchronizing pairs of replicas. However, it is 723 possible to use it to keep larger groups of machines in sync by performing 724 multiple pairwise synchronizations. 725 726 If you need to do this, the most reliable way to set things up is to 727 organize the machines into a ``star topology,'' with one machine designated 728 as the ``hub'' and the rest as ``spokes,'' and with each spoke machine 729 synchronizing only with the hub. The big advantage of the star topology is 730 that it eliminates the possibility of confusing ``spurious conflicts'' 731 arising from the fact that a separate archive is maintained by Unison for 732 every pair of hosts that it synchronizes. 733 734 735 \SUBSECTION{Going Further}{further} 736 737 On-line documentation for the various features of Unison 738 can be obtained either by typing 739 \begin{verbatim} 740 unison -doc topics 741 \end{verbatim} 742 \noindent 743 at the command line, or by selecting the Help menu in the graphical 744 user interface. 745 \iftextversion 746 The same information is also available in a typeset User's 747 Manual (HTML or PostScript format) through 748 \ONEURL{https://github.com/bcpierce00/unison/wiki}. 749 \else 750 The on-line information and the printed manual are essentially identical. 751 \fi 752 753 If you use Unison regularly, you should subscribe to one of the mailing 754 lists, to receive announcements of new versions. See 755 \sectionref{obtaining}{Obtaining Unison}. 756 757 \SECTION{Basic Concepts}{basics}{basics} 758 759 To understand how Unison works, it is necessary to discuss a few 760 straightforward concepts. 761 762 These concepts are developed more rigorously and at more length in a number 763 of papers, available at \ONEURL{http://www.cis.upenn.edu/\home{bcpierce}/papers}. 764 But the informal presentation here should be enough for most users. 765 766 767 \SUBSECTION{Roots}{roots} 768 769 A replica's {\em root} tells Unison where to find a set of files to be 770 synchronized, either on the local machine or on a remote host. 771 For example, 772 \begin{alltt} 773 \NT{relative/path/of/root} 774 \end{alltt} 775 \noindent 776 specifies a local root relative to the directory where Unison is 777 started, while 778 \begin{alltt} 779 /\NT{absolute/path/of/root} 780 \end{alltt} 781 \noindent 782 specifies a root relative to the top of the local filesystem, 783 independent of where Unison is running. Remote roots can begin with 784 \verb|ssh://| 785 to indicate that the remote server should be started with ssh: 786 \begin{alltt} 787 ssh://\NT{remotehost}//\NT{absolute/path/of/root} 788 ssh://\NT{user}@\NT{remotehost}/\NT{relative/path/of/root} 789 \end{alltt} 790 If the remote server is already running (in the socket mode), then the syntax 791 \begin{alltt} 792 socket://\NT{remotehost}:\NT{portnum}//\NT{absolute/path/of/root} 793 socket://\NT{remotehost}:\NT{portnum}/\NT{relative/path/of/root} 794 socket://[\NT{IPv6literal}]:\NT{portnum}/\NT{path} 795 \end{alltt} 796 \noindent 797 is used to specify the hostname and the port that the client Unison should 798 use to contact it. 799 Syntax 800 \begin{alltt} 801 socket://\{\NT{path/of/socket}\}//\NT{absolute/path/of/root} 802 socket://\{\NT{path/of/socket}\}/\NT{relative/path/of/root} 803 \end{alltt} 804 \noindent 805 is used to specify the Unix domain socket the client Unison should use to 806 contact the server. 807 808 The syntax for roots is based on that of URIs (described in RFC 2396). 809 The full grammar is: 810 \begin{alltt} 811 \NT{replica} ::= [\NT{protocol}:]//[\NT{user}@][\NT{host}][:\NT{port}][/\NT{path}] 812 | \NT{path} 813 814 \NT{protocol} ::= file 815 | socket 816 | ssh 817 818 \NT{user} ::= [-\_a-zA-Z0-9\%@]+ 819 820 \NT{host} ::= [-\_a-zA-Z0-9.]+ 821 | \textbackslash[ [a-f0-9:.]+ \NT{zone}? \textbackslash] IPv6 literals (no future format). 822 | \{ [\^{}\}]+ \} For Unix domain sockets only. 823 824 \NT{zone} ::= \%[-\_a-zA-Z0-9~\%.]+ 825 826 \NT{port} ::= [0-9]+ 827 \end{alltt} 828 When \verb|path| is given without any protocol prefix, the protocol is 829 assumed to be \verb|file:|. Under Windows, it is possible to 830 synchronize with a remote directory using the \verb|file:| protocol over 831 the Windows Network Neighborhood. For example, 832 \begin{verbatim} 833 unison foo //host/drive/bar 834 \end{verbatim} 835 \noindent 836 synchronizes the local directory \verb|foo| with the directory 837 \verb|drive:\bar| on the machine \verb|host|, provided that \verb|host| 838 is accessible via Network Neighborhood. When the \verb|file:| protocol 839 is used in this way, there is no need for a Unison server to be running 840 on the remote host. However, running Unison this way is only a good 841 idea if the remote host is reached by a very fast network connection, 842 since the full contents of every file in the remote replica will have to 843 be transferred to the local machine to detect updates. 844 845 The names of roots are {\em canonized} by Unison before it uses them 846 to compute the names of the corresponding archive files, so {\tt 847 //saul//home/bcpierce/common} and {\tt //saul.cis.upenn.edu/common} 848 will be recognized as the same replica under different names. 849 850 \SUBSECTION{Paths}{paths} 851 852 A {\em path} refers to a point {\em within} a set of files being 853 synchronized; it is specified relative to the root of the replica. 854 855 Formally, a path is just a sequence of names, separated by \verb|/|. 856 Note that the path separator character is always a forward slash, no 857 matter what operating system Unison is running on. Forward slashes 858 are converted to backslashes as necessary when paths are converted to 859 filenames in the local filesystem on a particular host. 860 % 861 (For example, suppose that we run Unison on a Windows system, synchronizing 862 the local root \verb|c:\pierce| with the root 863 \verb|ssh://saul.cis.upenn.edu/home/bcpierce| on a Unix server. Then 864 the path \verb|current/todo.txt| refers to the file 865 \verb|c:\pierce\current\todo.txt| on the client and 866 \verb|/home/bcpierce/current/todo.txt| on the server.) 867 868 The empty path (i.e., the empty sequence of names) denotes the whole 869 replica. Unison displays the empty path as ``\verb|[root]|.'' 870 871 If \verb|p| is a path and \verb|q| is a path beginning with \verb|p|, then 872 \verb|q| is said to be a {\em descendant} of \verb|p|. (Each path is also a 873 descendant of itself.) 874 875 876 \SUBSECTION{What is an Update?}{updates} 877 878 The {\em contents} of a path \verb|p| in a particular replica could be a 879 file, a directory, a symbolic link, or absent (if \verb|p| does not 880 refer to anything at all in that replica). More specifically: 881 \begin{itemize} 882 \item If \verb|p| refers to an ordinary file, then the 883 contents of \verb|p| are the actual contents of this file (a string of bytes) 884 plus the current permission bits of the file. 885 \item If \verb|p| refers to a symbolic link, then the contents of \verb|p| 886 are just the string specifying where the link points. 887 \item If \verb|p| refers to a directory, then the 888 contents of \verb|p| are just the token ``DIRECTORY'' plus the current 889 permission bits of the directory. 890 \item If \verb|p| does not refer to anything in this replica, then the 891 contents of \verb|p| are the token ``ABSENT.'' 892 \end{itemize} 893 Unison keeps a record of the contents of each path after each 894 successful synchronization of that path (i.e., it remembers the 895 contents at the last moment when they were the same in the two 896 replicas). 897 898 We say that a path is {\em updated} (in some replica) if its current 899 contents are different from its contents the last time it was successfully 900 synchronized. Note that whether a path is updated has nothing to do with 901 its last modification time---Unison considers only the contents when 902 determining whether an update has occurred. This means that touching a file 903 without changing its contents will {\em not} be recognized as an update. A 904 file can even be changed several times and then changed back to its original 905 contents; as long as Unison is only run at the end of this process, no 906 update will be recognized. 907 908 What Unison actually calculates is a close approximation to this 909 definition; see \sectionref{caveats}{Caveats and Shortcomings}. 910 911 \SUBSECTION{What is a Conflict?}{conflicts} 912 913 A path is said to be {\em conflicting} if the following conditions all hold: 914 \begin{enumerate} 915 \item it has been updated in one replica, 916 \item it or any of its descendants has been updated in the other 917 replica, 918 and 919 \item its contents in the two replicas are not identical. 920 \end{enumerate} 921 922 \finishlater{Note that this isn't precisely what we implement, in the 923 case of directory permission changes!} 924 925 926 \SUBSECTION{Reconciliation}{recon} 927 928 Unison operates in several distinct stages: 929 \begin{enumerate} 930 \item On each host, it compares its archive file (which records 931 the state of each path in the replica when it was last synchronized) 932 with the current contents of the replica, to determine which paths 933 have been updated. 934 \item It checks for ``false conflicts'' --- paths that have been 935 updated on both replicas, but whose current values are identical. 936 These paths are silently marked as synchronized in the archive files 937 in both replicas. 938 \item It displays all the updated paths to the user. For updates that 939 do not conflict, it suggests a default action (propagating the new 940 contents from the updated replica to the other). Conflicting updates 941 are just displayed. The user is given an opportunity to examine the 942 current state of affairs, change the default actions for 943 nonconflicting updates, and choose actions for conflicting updates. 944 \item It performs the selected actions, one at a time. Each action is 945 performed by first transferring the new contents to a temporary file 946 on the receiving host, then atomically moving them into place. 947 \item It updates its archive files to reflect the new state of the 948 replicas. 949 \end{enumerate} 950 951 \TOPSUBSECTION{Invariants}{failures} 952 953 Given the importance and delicacy of the job that it performs, it is 954 important to understand both what a synchronizer does under normal 955 conditions and what can happen under unusual conditions such as system 956 crashes and communication failures. 957 958 % Unison deals with two sorts of information: the two replicas 959 % themselves and its own memory of the ``last synchronized state'' of 960 % each path in the replicas. The latter is what allows it to detect 961 % correctly which replica is new when a file been updated. Roughly, 962 % the sequence of actions that occur when Unison runs is: 963 % \begin{enumerate} 964 % \item It reads a private archive file stored with each replica 965 % and checks which paths on each replica have been updated. 966 % Technically, a path has been updated if its contents in a replica are 967 % different from the contents of that replica at the end of the last 968 % synchronization in which that path was successfully synchronized --- 969 % i.e., the last time the two replicas were equal at that path at the 970 % end of a run of Unison. The ``contents'' of a path can be either a 971 % file, a directory, or nothing at all, so deleting a file or changing a 972 % directory to a file count as updates to the contents at that path. 973 974 % For efficiency, Unison does not try to calculate the set of updated 975 % paths exactly: it will sometimes falsely detect a change in a path 976 % whose contents have actually not changed (this can happen, for 977 % example, when the file's modification time has been changed, for some 978 % reason). As long as this path has not been modified in the other 979 % replica, this ``conservativity'' in update detection is invisible to 980 % the user. If the other replica {\em has} been modified, however, a 981 % ``false conflict'' may be reported. 982 983 % \item It combines the lists of paths that (may) have been updated in 984 % the two replicas, assigns default actions to those where the change 985 % was in one replica only, and records a conflict for those that were 986 % changed in both replicas. 987 988 % \item The current contents of the paths on this list are then 989 % compared, to see if they actually differ. (This is done by comparing 990 % fingerprints, not transferring the whole files.) Paths whose contents 991 % are actually identical are marked as synchronized and deleted from the 992 % list. 993 994 % \item The remaining paths are displayed to the user, who then has an 995 % opportunity to change the default actions and choose actions for 996 % conflicting paths. 997 998 % \item When this process is finished, the selected changes are actually 999 % propagated between the replicas. 1000 1001 % \item Finally, Unison updates its internal state, marking as 1002 % synchronized all the files for which changes were successfully 1003 % propagated. 1004 % \end{enumerate} 1005 1006 Unison is careful to protect both its internal state and the state of 1007 the replicas at every point in this process. Specifically, the 1008 following guarantees are enforced: 1009 \begin{itemize} 1010 \item At every moment, each path in each replica has either (1) its {\em 1011 original} contents (i.e., no change at all has been made to this 1012 path), or (2) its {\em correct} final contents (i.e., the value that the 1013 user expected to be propagated from the other replica). 1014 \item At every moment, the information stored on disk about Unison's 1015 private state can be either (1) unchanged, or (2) updated to reflect 1016 those paths that have been successfully synchronized. 1017 \end{itemize} 1018 The upshot is that it is safe to interrupt Unison at any time, either 1019 manually or accidentally. [Caveat: the above is {\em almost} true there 1020 are occasionally brief periods where it is not (and, because of 1021 shortcoming of the Posix filesystem API, cannot be); in particular, when 1022 it is copying a file onto a directory or vice versa, it must first move 1023 the original contents out of the way. If Unison gets 1024 interrupted during one of these periods, some manual cleanup may be 1025 required. In this case, a file called {\tt DANGER.README} will be left 1026 in the {\tt .unison} directory, containing information about the operation that 1027 was interrupted. The next time you try to run Unison, it will notice this 1028 file and warn you about it.] 1029 1030 If an interruption happens while it is propagating updates, then there 1031 may be some paths for which an update has been propagated but which 1032 have not been marked as synchronized in Unison's archives. This is no 1033 problem: the next time Unison runs, it will detect changes to these 1034 paths in both replicas, notice that the contents are now equal, and 1035 mark the paths as successfully updated when it writes back its private 1036 state at the end of this run. 1037 1038 If Unison is interrupted, it may sometimes leave temporary working files 1039 (with suffix \verb|.tmp|) in the replicas. It is safe to delete these 1040 files. Also, if the \verb|backups| flag is set, Unison will 1041 leave around old versions of files that it overwrites, with names like 1042 \verb|file.0.unison.bak|. These can be deleted safely when they are no 1043 longer wanted. 1044 1045 Unison is not bothered by clock skew between the different hosts on 1046 which it is running. It only performs comparisons between timestamps 1047 obtained from the same host, and the only assumption it makes about 1048 them is that the clock on each system always runs forward. 1049 1050 If Unison finds that its archive files have been deleted (or that the 1051 archive format has changed and they cannot be read, or that they don't 1052 exist because this is the first run of Unison on these particular 1053 roots), it takes a conservative approach: it behaves as though the 1054 replicas had both been completely empty at the point of the last 1055 synchronization. The effect of this is that, on the first run, files 1056 that exist in only one replica will be propagated to the other, while 1057 files that exist in both replicas but are unequal will be marked as 1058 conflicting. 1059 1060 Touching a file without changing its contents should never affect whether or 1061 not Unison does an update. (When running with the fastcheck preference set 1062 to true---the default on Unix systems---Unison uses file modtimes for a 1063 quick first pass to tell which files have definitely not changed; then, for 1064 each file that might have changed, it computes a fingerprint of the file's 1065 contents and compares it against the last-synchronized contents. Also, the 1066 \verb|-times| option allows you to synchronize file times, but it does not 1067 cause identical files to be changed; Unison will only modify the file 1068 times.) 1069 1070 It is safe to ``brainwash'' Unison by deleting its archive files 1071 {\em on both replicas}. The next time it runs, it will assume that 1072 all the files it sees in the replicas are new. 1073 1074 It is safe to modify files while Unison is working. If Unison 1075 discovers that it has propagated an out-of-date change, or that the 1076 file it is updating has changed on the target replica, it will signal 1077 a failure for that file. Run Unison again to propagate the latest 1078 change. 1079 \finishlater{There are some race conditions. We should probably talk about them.} 1080 1081 Changes to the ignore patterns from the user interface (e.g., using 1082 the `i' key) are immediately reflected in the current profile. 1083 1084 1085 \SUBSECTION{Caveats and Shortcomings}{caveats} 1086 1087 Here are some things to be careful of when using Unison. 1088 1089 \begin{itemize} 1090 \item In the interests of speed, the update detection algorithm may 1091 (depending on which OS architecture that you run Unison on) 1092 actually use an approximation to the definition given in 1093 \sectionref{updates}{What is an Update?}. 1094 1095 In particular, the Unix 1096 implementation does not compare the actual contents of files to their 1097 previous contents, but simply looks at each file's inode number and 1098 modtime; if neither of these have changed, then it concludes that the 1099 file has not been changed. 1100 1101 Under normal circumstances, this approximation is safe, in the sense 1102 that it may sometimes detect ``false updates'' but will never miss a real 1103 one. However, it is possible to fool it, for example by using 1104 \verb|retouch| to change a file's modtime back to a time in the past. 1105 \finishlater{One user---Marcus Mottl---claimed that it could also 1106 happen if we use 1107 memory mapped I/O, but this is not clear} 1108 1109 \item If you synchronize between a single-user filesystem and a shared 1110 Unix server, you should pay attention to your permission bits: by 1111 default, Unison will synchronize permissions verbatim, which may leave 1112 group-writable files on the server that could be written over by a lot of 1113 people. 1114 1115 You can control this by setting your \verb|umask| on both computers to 1116 something like 022, masking out the ``world write'' and ``group write'' 1117 permission bits. 1118 1119 Unison does not synchronize the \verb|setuid| and \verb|setgid| bits, for 1120 security. 1121 1122 \item The graphical user interface is single-threaded. This 1123 means that if Unison is performing some long-running operation, the 1124 display will not be repainted until it finishes. We recommend not 1125 trying to do anything with the user interface while Unison is in the 1126 middle of detecting changes or propagating files. 1127 1128 \item Unison does not understand hard links. 1129 1130 \item It is important to be a little careful when renaming directories 1131 containing {\tt ignore}d files. 1132 1133 For example, suppose Unison is synchronizing directory A between the two 1134 machines called the ``local'' and the ``remote'' machine; suppose directory 1135 A contains a subdirectory D; and suppose D on the local machine contains a 1136 file or subdirectory P that matches an ignore directive in the profile used 1137 to synchronize. Thus path A/D/P exists on the local machine but not on the 1138 remote machine. 1139 1140 If D is renamed to D' on the remote machine, and this change is 1141 propagated to the local machine, all such files or subdirectories P 1142 will be deleted. This is because Unison sees the rename as a delete and a 1143 separate create: it deletes the old directory (including the ignored files) 1144 and creates a new one ({\em not} including the ignored files, since they 1145 are completely invisible to it). 1146 \end{itemize} 1147 1148 1149 1150 \SECTION{Reference Guide}{reference}{ } 1151 1152 This section covers the features of Unison in detail. 1153 1154 \TOPSUBSECTION{Running Unison}{running} 1155 1156 There are several ways to start Unison. 1157 \begin{itemize} 1158 \item Typing ``{\tt unison \NT{profile}}'' on the command line. Unison 1159 will look for a file \texttt{\NT{profile}.prf} in the \verb|.unison| 1160 directory. If this file does not specify a pair of roots, Unison will 1161 prompt for them and add them to the information specified by the profile. 1162 \item Typing ``{\tt unison \NT{profile} \NT{root1} \NT{root2}}'' on the command 1163 line. 1164 In this case, Unison will use {\tt \NT{profile}}, which should not contain 1165 any {\tt root} directives. 1166 \item Typing ``{\tt unison \NT{root1} \NT{root2}}'' on the command line. This 1167 has the same effect as typing ``{\tt unison default \NT{root1} \NT{root2}}.'' 1168 \item Typing just ``{\tt unison}'' (or invoking Unison by clicking on 1169 a desktop icon). In this case, Unison will ask for the profile to use 1170 for synchronization (or create a new one, if necessary). 1171 \end{itemize} 1172 1173 % \finish{Need to check that the text UI actually works this way. (It 1174 % doesn't prompt, for sure, but it should.)} 1175 1176 \SUBSECTION{The {\tt .unison} Directory}{unisondir} 1177 1178 Unison stores a variety of information in a private directory on each 1179 host. If the environment variable {\tt UNISON} is defined, then its 1180 value will be used as the path/folder name for this directory. 1181 This can be just a name, or a path. 1182 1183 A name on it's own, for example {\tt UNISON=mytestname} will 1184 place a folder in the same directory that the Unison binary was run 1185 in, with that name. Using a path like {\tt UNISON=../mytestname2} 1186 will place that folder in the folder above where the Unison binary was 1187 run from. 1188 1189 If {\tt UNISON} is not defined, then the directory depends on which 1190 operating system you are using. In Unix, the default is to use 1191 {\tt \$HOME/.unison}. 1192 In Windows, if the environment variable 1193 {\tt USERPROFILE} is defined, then the directory will be 1194 {\tt \$USERPROFILE$\backslash$.unison}; 1195 otherwise if {\tt HOME} is defined, it will be 1196 {\tt \$HOME$\backslash$.unison}; 1197 otherwise, it will be 1198 {\tt c:$\backslash$.unison}. 1199 On OS X, 1200 {\tt \$HOME/.unison} will be used if it is present, but 1201 {\tt \$HOME/Library/Application Support/Unison} will be created and used by 1202 default. 1203 1204 The archive file for each replica is found in the {\tt .unison} 1205 directory on that replica's host. Profiles (described below) are 1206 always taken from the {\tt .unison} directory on the client host. 1207 1208 Note that Unison maintains a completely different set of archive files 1209 for each pair of roots. 1210 1211 We do not recommend synchronizing the whole {\tt .unison} directory, as this 1212 will involve frequent propagation of large archive files. It should be safe 1213 to do it, though, if you really want to. Synchronizing just the profile 1214 files in the {\tt .unison} directory is definitely OK. 1215 1216 1217 \SUBSECTION{Archive Files}{archives} 1218 1219 The name of the archive file on each replica is calculated from 1220 \begin{itemize} 1221 \item the {\em canonical names} of all the hosts (short names like 1222 \verb|saul| are converted into full addresses like \verb|saul.cis.upenn.edu|), 1223 \item the paths to the replicas on all the hosts (again, relative 1224 pathnames, symbolic links, etc.\ are converted into full, absolute paths), and 1225 \item an internal version number that is changed whenever a new Unison 1226 release changes the format of the information stored in the archive. 1227 \end{itemize} 1228 This method should work well for most users. However, it is occasionally 1229 useful to change the way archive names are generated. Unison provides 1230 two ways of doing this. 1231 1232 The function that finds the canonical hostname of the local host (which 1233 is used, for example, in calculating the name of the archive file used to 1234 remember which files have been synchronized) normally uses the 1235 \verb|gethostname| operating system call. However, if the environment 1236 variable \verb|UNISONLOCALHOSTNAME| is set, its value will be used 1237 instead. This makes it easier to use Unison in situations where a 1238 machine's name changes frequently (e.g., because it is a laptop and gets 1239 moved around a lot). 1240 1241 A more powerful way of changing archive names is provided by the 1242 \verb|rootalias| preference. The preference file may contain any number of 1243 lines of the form: 1244 \begin{alltt} 1245 rootalias = //\NT{hostnameA}//\NT{path-to-replicaA} -> //\NT{hostnameB}/\NT{path-to-replicaB} 1246 \end{alltt} 1247 When calculating the name of the archive files for a given pair of roots, 1248 Unison replaces any root that matches the left-hand side of any rootalias 1249 rule by the corresponding right-hand side. 1250 1251 So, if you need to relocate a root on one of the hosts, you can add a 1252 rule of the form: 1253 \begin{alltt} 1254 rootalias = //\NT{new-hostname}//\NT{new-path} -> //\NT{old-hostname}/\NT{old-path} 1255 \end{alltt} 1256 Note that root aliases are case-sensitive, even on case-insensitive file 1257 systems. 1258 1259 {\em Warning}: The \verb|rootalias| option is dangerous and should only 1260 be used if you are sure you know what you're doing. In particular, it 1261 should only be used if you are positive that either (1) both the original 1262 root and the new alias refer to the same set of files, or (2) the files 1263 have been relocated so that the original name is now invalid and will 1264 never be used again. (If the original root and the alias refer to 1265 different sets of files, Unison's update detector could get confused.) 1266 % 1267 After introducing a new \verb|rootalias|, it is a good idea to run Unison 1268 a few times interactively (with the \verb|batch| flag off, etc.) and 1269 carefully check that things look reasonable---in particular, that update 1270 detection is working as expected. 1271 1272 1273 \SUBSECTION{Preferences}{prefs} 1274 1275 Many details of Unison's behavior are configurable by user-settable 1276 ``preferences.'' 1277 1278 Some preferences are boolean-valued; these are often called {\em flags}. 1279 Others take numeric or string arguments, indicated in the preferences 1280 list by {\tt n} or {\tt xxx}. Some string arguments take the backslash as 1281 an escape to include the next character literally; this is mostly useful 1282 to escape a space or the backslash; a trailing backslash is ignored and is 1283 useful to protect a trailing whitespace in the string that would otherwise 1284 be trimmed. Most of the string preferences can be given several times; 1285 the arguments are accumulated into a list internally. 1286 1287 There are two ways to set the values of preferences: temporarily, by 1288 providing command-line arguments to a particular run of Unison, or 1289 permanently, by adding commands to a {\em profile} in the {\tt .unison} 1290 directory on the client host. The order of preferences (either on the 1291 command line or in preference files) is not significant. On the command 1292 line, preferences and other arguments (the profile name and roots) can be 1293 intermixed in any order. 1294 1295 To set the value of a preference {\tt p} from the command line, add an 1296 argument {\tt -p} (for a boolean flag) or {\tt -p n} or {\tt -p xxx} (for 1297 a numeric or string preference) anywhere on the command line. To set a 1298 boolean flag to \verb|false| on the command line, use {\tt -p=false}. 1299 1300 Here are all the preferences supported by Unison. This list can be 1301 obtained by typing {\tt unison -help}. 1302 \begin{quote} 1303 \verbatiminput{prefs.tmp} 1304 \end{quote} 1305 1306 Here, in more detail, is what they do. Many are discussed in greater detail 1307 in other sections of the manual. 1308 1309 It should be noted that some command-line arguments are handled specially during startup, including \verb|-doc|, \verb|-help|, \verb|-version|, \verb|-socket|, and \verb|-ui|. They are expected to appear on the command-line only, not in a profile. In particular, \verb|-version| and \verb|-doc| will print to the standard output, so they only make sense if invoked from the command-line (and not a click-launched gui that has no standard output). Furthermore, the actions associated with these command-line arguments are executed without loading a profile or doing the usual command-line parsing. 1310 % 1311 \input{prefsdocs.tmp} 1312 1313 1314 \SUBSECTION{Profiles}{profile} 1315 1316 A {\em profile} is a text file that specifies permanent settings for 1317 roots, paths, ignore patterns, and other preferences, so that they do 1318 not need to be typed at the command line every time Unison is run. 1319 Profiles should reside in the \verb|.unison| directory on the client 1320 machine. If Unison is started with just one argument \ARG{name} on 1321 the command line, it looks for a profile called \texttt{\ARG{name}.prf} in 1322 the \verb|.unison| directory. If it is started with no arguments, it 1323 scans the \verb|.unison| directory for files whose names end in 1324 \verb|.prf| and offers a menu (provided that the Unison executable is compiled with the graphical user interface). If a file named \verb|default.prf| is 1325 found, its settings will be offered as the default choices. 1326 1327 To set the value of a preference {\tt p} permanently, add to the 1328 appropriate profile a line of the form 1329 \begin{verbatim} 1330 p = true 1331 \end{verbatim} 1332 for a boolean flag or 1333 \begin{verbatim} 1334 p = <value> 1335 \end{verbatim} 1336 for a preference of any other type. 1337 1338 A profile may include blank lines and lines beginning 1339 with {\tt \#}; both are ignored. 1340 1341 Spaces and tabs before and after {\tt p} and {\tt xxx} are ignored. 1342 Spaces, tabs, and non-printable characters within values are not 1343 treated specially, so that e.g. \verb|root = /foo bar| refers to a 1344 directory containing a space. 1345 (On systems using newline for line ending, carriage returns are 1346 currently ignored, but this is not part of the specification.) 1347 1348 When Unison starts, it first reads the profile and then the command 1349 line, so command-line options will override settings from the 1350 profile. 1351 1352 Profiles may also include lines of the form \texttt{include \ARG{name}}, 1353 which will cause the file \ARG{name} (or \texttt{\ARG{name}.prf}, if 1354 \ARG{name} does not exist in the \verb+.unison+ directory) to be read at 1355 the point, and included as if its contents, instead of the \texttt{include} 1356 line, was part of the profile. Include lines allows settings common to 1357 several profiles to be stored in one place. 1358 A similar line of the form \texttt{source \ARG{name}} does the same except 1359 that it does not attempt to add a suffix to \ARG{name}. 1360 Similar lines of the form \texttt{include\mbox{?} \ARG{name}} or 1361 \texttt{source\mbox{?} \ARG{name}} do the same as their respective lines 1362 without the question mark except that it does not constitute an error to 1363 specify a non-existing file \ARG{name}. 1364 In \ARG{name} the backslash is an escape character. 1365 1366 A profile may include a preference `\texttt{label = \ARG{desc}}' to 1367 provide a description of the options selected in this profile. The 1368 string \ARG{desc} is listed along with the profile name in the profile 1369 selection dialog, and displayed in the top-right corner of the main 1370 Unison window in the graphical user interface. 1371 1372 The graphical user-interface also supports one-key shortcuts for commonly 1373 used profiles. If a profile contains a preference of the form 1374 % 1375 `\texttt{key = \ARG{n}}', where \ARG{n} is a single digit, then 1376 pressing this digit key will cause Unison to immediately switch to 1377 this profile and begin synchronization again from scratch. In this 1378 case, all actions that have been selected for a set of changes 1379 currently being displayed will be discarded. 1380 1381 1382 \SUBSECTION{Sample Profiles}{profileegs} 1383 1384 \SUBSUBSECTION{A Minimal Profile}{minimalprofile} 1385 1386 Here is a very minimal profile file, such as might be found in {\tt 1387 .unison/default.prf}: 1388 \begin{verbatim} 1389 # Roots of the synchronization 1390 root = /home/bcpierce 1391 root = ssh://saul//home/bcpierce 1392 1393 # Paths to synchronize 1394 path = current 1395 path = common 1396 path = .netscape/bookmarks.html 1397 \end{verbatim} 1398 1399 \SUBSUBSECTION{A Basic Profile}{basicprofile} 1400 1401 Here is a more sophisticated profile, illustrating some other useful 1402 features. 1403 \begin{verbatim} 1404 # Roots of the synchronization 1405 root = /home/bcpierce 1406 root = ssh://saul//home/bcpierce 1407 1408 # Paths to synchronize 1409 path = current 1410 path = common 1411 path = .netscape/bookmarks.html 1412 1413 # Some regexps specifying names and paths to ignore 1414 ignore = Name temp.* 1415 ignore = Name *~ 1416 ignore = Name .*~ 1417 ignore = Path */pilot/backup/Archive_* 1418 ignore = Name *.o 1419 ignore = Name *.tmp 1420 1421 # Window height 1422 height = 37 1423 1424 # Keep a backup copy of every file in a central location 1425 backuplocation = central 1426 backupdir = /home/bcpierce/backups 1427 backup = Name * 1428 backupprefix = $VERSION. 1429 backupsuffix = 1430 1431 # Use this command for displaying diffs 1432 diff = diff -y -W 79 --suppress-common-lines 1433 1434 # Log actions to the terminal 1435 log = true 1436 \end{verbatim} 1437 1438 \SUBSUBSECTION{A Power-User Profile}{powerprofile} 1439 1440 When Unison is used with large replicas, it is often convenient to be 1441 able to synchronize just a part of the replicas on a given run (this 1442 saves the time of detecting updates in the other parts). This can be 1443 accomplished by splitting up the profile into several parts --- a common 1444 part containing most of the preference settings, plus one ``top-level'' 1445 file for each set of paths that need to be synchronized. (The {\tt 1446 include} mechanism can also be used to allow the same set of preference 1447 settings to be used with different roots.) 1448 1449 The collection 1450 of profiles implementing this scheme might look as follows. 1451 % 1452 The file {\tt default.prf} is empty except for an {\tt include} 1453 directive: 1454 \begin{verbatim} 1455 # Include the contents of the file common 1456 include common 1457 \end{verbatim} 1458 Note that the name of the common file is {\tt common}, not {\tt 1459 common.prf}; this prevents Unison from offering {\tt common} as one of 1460 the list of profiles in the opening dialog (in the graphical UI). 1461 1462 The file {\tt common} contains the real preferences: 1463 \begin{verbatim} 1464 # Roots of the synchronization 1465 root = /home/bcpierce 1466 root = ssh://saul//home/bcpierce 1467 1468 # (... other preferences ...) 1469 1470 # If any new preferences are added by Unison (e.g. 'ignore' 1471 # preferences added via the graphical UI), then store them in the 1472 # file 'common' rather than in the top-level preference file 1473 addprefsto = common 1474 1475 # Names and paths to ignore: 1476 ignore = Name temp.* 1477 ignore = Name *~ 1478 ignore = Name .*~ 1479 ignore = Path */pilot/backup/Archive_* 1480 ignore = Name *.o 1481 ignore = Name *.tmp 1482 \end{verbatim} 1483 Note that there are no {\tt path} preferences in {\tt common}. This 1484 means that, when we invoke Unison with the default profile (e.g., by 1485 typing '{\tt unison default}' or just '{\tt unison}' on the command 1486 line), the whole replicas will be synchronized. (If we {\em never} want 1487 to synchronize the whole replicas, then {\tt default.prf} would instead 1488 include settings for all the paths that are usually synchronized.) 1489 1490 To synchronize just part of the replicas, Unison is invoked with an 1491 alternate preference file---e.g., doing '{\tt unison workingset}', where the 1492 preference file {\tt workingset.prf} contains 1493 \begin{verbatim} 1494 path = current/papers 1495 path = Mail/inbox 1496 path = Mail/drafts 1497 include common 1498 \end{verbatim} 1499 causes Unison to synchronize just the listed subdirectories. 1500 1501 The {\tt key} preference can be used in combination with the graphical UI 1502 to quickly switch between different sets of paths. For example, if the 1503 file {\tt mail.prf} contains 1504 \begin{verbatim} 1505 path = Mail 1506 batch = true 1507 key = 2 1508 include common 1509 \end{verbatim} 1510 then pressing 2 will cause Unison to look for updates in the {\tt Mail} 1511 subdirectory and (because the {\tt batch} flag is set) immediately 1512 propagate any that it finds. 1513 1514 1515 \SUBSECTION{Keeping Backups}{backups} 1516 1517 When Unison overwrites (or deletes) a file or directory while propagating changes from 1518 the other replica, it can keep the old version around as a backup. There 1519 are several preferences that control precisely where these backups are 1520 stored and how they are named. 1521 1522 To enable backups, you must give one or more \verb|backup| preferences. 1523 Each of these has the form 1524 \begin{verbatim} 1525 backup = <pathspec> 1526 \end{verbatim} 1527 where \verb|<pathspec>| has the same form as for the \verb|ignore| 1528 preference. For example, 1529 \begin{verbatim} 1530 backup = Name * 1531 \end{verbatim} 1532 causes Unison to create backups of {\em all} files and directories. The 1533 \verb|backupnot| preference can be used to give a few exceptions: it 1534 specifies which files and directories should {\em not} be backed up, even if 1535 they match the \verb|backup| pathspec. 1536 1537 It is important to note that the \verb|pathspec| is matched against the path 1538 that is being updated by Unison, not its descendants. For example, if you 1539 set \verb|backup = Name *.txt| and then delete a whole directory named 1540 \verb|foo| containing some text files, these files will not be backed up 1541 because Unison will just check that \verb|foo| does not match \verb|*.txt|. 1542 Similarly, if the directory itself happened to be called \verb|foo.txt|, 1543 then the whole directory and all the files in it will be backed up, 1544 regardless of their names. 1545 1546 Backup files can be stored either {\em centrally} or {\em locally}. This 1547 behavior is controlled by the preference \verb|backuplocation|, whose value 1548 must be either \verb|central| or \verb|local|. (The default is 1549 \verb|central|.) Note that central storage of backups can lead to 1550 backup files being stored in a different filesystem than the original 1551 files, which could have different security properties and different 1552 amounts of available storage. 1553 1554 When backups are stored locally, they are kept in the same 1555 directory as the original. 1556 1557 When backups are stored centrally, the directory used to hold them is 1558 controlled by the preference \verb|backupdir| and the 1559 environment variable \verb|UNISONBACKUPDIR|. (The environment variable is 1560 checked first.) If neither of these are set, then the directory 1561 \verb|.unison/backup| in the user's home directory is used. 1562 1563 The preference \verb|maxbackups| (default 2) controls how many 1564 previous versions of each file are kept (including the current 1565 version), following the usual plan of deleting the oldest when 1566 creating a new one. 1567 1568 By default, backup files are named \verb|.bak.VERSION.FILENAME|, 1569 where \verb|FILENAME| is the original filename and \verb|VERSION| is the 1570 backup number (1 for the most recent, 2 for the next most recent, 1571 etc.). This can be changed by setting the preferences \verb|backupprefix| 1572 and/or \verb|backupsuffix|. If desired, \verb|backupprefix| may include a 1573 directory prefix; this can be used with \verb|backuplocation = local| to put all 1574 backup files for each directory into a single subdirectory. For example, setting 1575 \begin{verbatim} 1576 backuplocation = local 1577 backupprefix = .unison/$VERSION. 1578 backupsuffix = 1579 \end{verbatim} 1580 will put all backups in a local subdirectory named \verb|.unison|. Also, 1581 note that the string \verb|$VERSION| in either \verb|backupprefix| or 1582 \verb|backupsuffix| (it must appear in one or the other) is replaced by 1583 the version number. This can be used, for example, to ensure that backup 1584 files retain the same extension as the originals. 1585 1586 Other than \verb|maxbackups| (which will never delete the last 1587 backup), there are no other mechanisms for deleting backups. 1588 1589 For backward compatibility, the \verb|backups| preference is also supported. 1590 % 1591 It simply means \verb|backup = Name *| and \verb|backuplocation = local|. 1592 1593 1594 \SUBSECTION{Merging Conflicting Versions}{merge} 1595 1596 Unison can invoke external programs to merge conflicting versions of a file. 1597 The preference \verb|merge| controls this process. 1598 1599 The \verb|merge| preference may be given once or several times in a 1600 preference file (it can also be given on the command line, of course, but 1601 this tends to be awkward because of the spaces and special characters 1602 involved). Each instance of the preference looks like this: 1603 \begin{verbatim} 1604 merge = <PATHSPEC> -> <MERGECMD> 1605 \end{verbatim} 1606 The \verb|<PATHSPEC>| here has exactly the same format as for the 1607 \verb|ignore| preference (see \sectionref{pathspec}{Path Specification}). For example, 1608 using ``\verb|Name *.txt|'' as the \verb|<PATHSPEC>| tells Unison that this 1609 command should be used whenever a file with extension \verb|.txt| needs to 1610 be merged. 1611 1612 Many external merging programs require as inputs not just the two files that 1613 need to be merged, but also a file containing the {\em last synchronized 1614 version}. You can ask Unison to keep a copy of the last synchronized 1615 version for some files using the \verb|backupcurrent| preference. This 1616 preference is used in exactly the same way as \verb|backup| and its meaning 1617 is similar, except that it causes backups to be created of the {\em current} 1618 contents of each file after it has been synchronized by Unison, rather than 1619 the {\em previous} contents that Unison overwrote. These backups are stored 1620 in {\em both} replicas in the same place as ordinary backup files---i.e. 1621 according to the \verb|backuplocation| and \verb|backupdir| preferences. 1622 They are named like the original files if \verb|backupslocation| is set to 1623 'central' and otherwise, Unison uses the \verb|backupprefix| and 1624 \verb|backupsuffix| preferences and assumes a version number 000 for these 1625 backups. Note that there are no mechanisms (beyond the limit on the number of 1626 backups for each file) to remove backup files. 1627 1628 The \verb|<MERGECMD>| part of the preference specifies what external command 1629 should be invoked to merge files at paths matching the \verb|<PATHSPEC>|. 1630 Within this string, several special substrings are recognized; these will be 1631 substituted with appropriate values before invoking a sub-shell to execute 1632 the command. 1633 \begin{itemize} 1634 \item \relax\verb|CURRENT1| is replaced by the name of (a temporary copy of) 1635 the local variant of the file. 1636 \item \relax\verb|CURRENT2| is replaced by the name of a temporary 1637 file, into which the contents of the remote variant of the file have 1638 been transferred by Unison prior to performing the merge. 1639 \item \relax\verb|CURRENTARCH| is replaced by the name of the backed up copy 1640 of the original version of the file (i.e., the file saved by Unison 1641 if the current filename matches the path specifications for the 1642 \verb|backupcurrent| preference, as explained above), if one exists. 1643 If no archive exists and \relax\verb|CURRENTARCH| appears in the 1644 merge command, then an error is signalled. 1645 \item \relax\verb|CURRENTARCHOPT| is replaced by the name of the backed up copy 1646 of the original version of the file (i.e., its state at the end of 1647 the last successful run of Unison), if one exists, or the empty 1648 string if no archive exists. 1649 \item \relax\verb|NEW| is replaced by the name of a temporary file 1650 that Unison expects to be written by the merge program when it 1651 finishes, giving the desired new contents of the file. 1652 \item \relax\verb|PATH| is replaced by the path (relative to the roots of 1653 the replicas) of the file being merged. 1654 \item \relax\verb|NEW1| and \relax\verb|NEW2| are replaced by the names of temporary files 1655 that Unison expects to be written by the merge program when it 1656 is only able to partially merge the originals; in this case, \verb|NEW1| 1657 will be written back to the local replica and \verb|NEW2| to the remote 1658 replica; \verb|NEWARCH|, if present, will be used as the ``last common 1659 state'' of the replicas. (These three options are provided for 1660 later compatibility with the Harmony data synchronizer.) 1661 \item \relax\verb|BATCHMODE| is replaced according to the batch mode of 1662 Unison; if it is in \texttt{batch} mode, then a non empty string 1663 (``\verb|batch|'') is substituted, otherwise the empty string is substituted. 1664 \end{itemize} 1665 To accommodate the wide variety of programs that users might want to use for 1666 merging, Unison checks for several possible situations when the merge 1667 program exits: 1668 \begin{itemize} 1669 \item If the merge program exits with a non-zero status, then merge is 1670 considered to have failed and the replicas are not changed. 1671 \item If the file \verb|NEW| has been created, it is written back to both 1672 replicas (and stored in the backup directory). Similarly, if just the 1673 file \verb|NEW1| has been created, it is written back to both 1674 replicas. 1675 \item If neither \verb|NEW| nor \verb|NEW1| have been created, then Unison 1676 examines the temporary files \verb|CURRENT1| and \verb|CURRENT2| that 1677 were given as inputs to the merge program. If either has been changed (or 1678 both have been changed in identical ways), then its new contents are written 1679 back to both replicas. If either \verb|CURRENT1| or \verb|CURRENT2| has 1680 been {\em deleted}, then the contents of the other are written back to 1681 both replicas. 1682 \item If the files \verb|NEW1|, \verb|NEW2|, and \verb|NEWARCH| have all 1683 been created, they are written back to the local replica, remote replica, 1684 and backup directory, respectively. If the files \verb|NEW1|, \verb|NEW2| have 1685 been created, but \verb|NEWARCH| has not, then these files are written back to the 1686 local replica and remote replica, respectively. Also, if \verb|NEW1| and 1687 \verb|NEW2| have identical contents, then the same contents are stored as 1688 a backup (if the \verb|backupcurrent| preference is set for this path) to 1689 reflect the fact that the path is currently in sync. 1690 \item If \verb|NEW1| and \verb|NEW2| (resp. \verb|CURRENT1| and 1691 \verb|CURRENT2|) are created (resp. overwritten) with different contents 1692 but the merge command did not fail (i.e., it exited with status code 0), 1693 then we copy \verb|NEW1| (resp. \verb|CURRENT1|) to the other replica and 1694 to the archive. 1695 1696 This behavior is a design choice made to handle the case where a merge 1697 command only synchronizes some specific contents between two files, 1698 skipping some irrelevant information (order between entries, for 1699 instance). We assume that, if the merge command exits normally, then the 1700 two resulting files are ``as good as equal.'' (The reason we copy one on 1701 top of the other is to avoid Unison detecting that the files are unequal 1702 the next time it is run and trying again to merge them when, in fact, the 1703 merge program has already made them as similar as it is able to.) 1704 \end{itemize} 1705 1706 You can disable a merge by setting a \verb|<MERGECMD>| that does nothing. For 1707 example you can override the merging of text files specified in a profile by 1708 typing on the command line: 1709 \begin{verbatim} 1710 unison profile -merge 'Name *.txt -> echo SKIP' 1711 \end{verbatim} 1712 1713 If the \verb|confirmmerge| preference is set and Unison is not run in 1714 batch mode, then Unison will always ask for confirmation before 1715 actually committing the results of the merge to the replicas. 1716 1717 You can detect batch mode by testing \verb|BATCHMODE|; for 1718 example to avoid a merge completely do nothing: 1719 \begin{verbatim} 1720 merge = Name *.txt -> [ -z "BATCHMODE" ] && mergecmd CURRENT1 CURRENT2 1721 \end{verbatim} 1722 1723 A large number of external merging programs are available. 1724 For example, on Unix systems setting the \verb|merge| preference to 1725 \begin{verbatim} 1726 merge = Name *.txt -> diff3 -m CURRENT1 CURRENTARCH CURRENT2 1727 > NEW || echo "differences detected" 1728 \end{verbatim} 1729 \noindent 1730 will tell Unison to use the external \verb|diff3| program for merging. 1731 % 1732 Alternatively, users of \verb|emacs| may find the following settings convenient: 1733 \begin{verbatim} 1734 merge = Name *.txt -> emacs -q --eval '(ediff-merge-files-with-ancestor 1735 "CURRENT1" "CURRENT2" "CURRENTARCH" nil "NEW")' 1736 \end{verbatim} 1737 \noindent 1738 (These commands are displayed here on two lines to avoid running off the 1739 edge of the page. In your preference file, each command should be written on a 1740 single line.) 1741 1742 Users running emacs under windows may find something like this useful: 1743 \begin{verbatim} 1744 merge = Name * -> C:\Progra~1\Emacs\emacs\bin\emacs.exe -q --eval 1745 "(ediff-files """CURRENT1""" """CURRENT2""")" 1746 \end{verbatim} 1747 1748 Users running Mac OS X (you may need the Developer Tools installed to get 1749 the {\tt opendiff} utility) may prefer 1750 \begin{verbatim} 1751 merge = Name *.txt -> opendiff CURRENT1 CURRENT2 -ancestor CURRENTARCH -merge NEW 1752 \end{verbatim} 1753 Here is a slightly more involved hack. The {\tt opendiff} program can 1754 operate either with or without an archive file. A merge command of this 1755 form 1756 \begin{verbatim} 1757 merge = Name *.txt -> 1758 if [ CURRENTARCHOPTx = x ]; 1759 then opendiff CURRENT1 CURRENT2 -merge NEW; 1760 else opendiff CURRENT1 CURRENT2 -ancestor CURRENTARCHOPT -merge NEW; 1761 fi 1762 \end{verbatim} 1763 (still all on one line in the preference file!) will test whether an archive 1764 file exists and use the appropriate variant of the arguments to {\tt 1765 opendiff}. 1766 1767 Linux users may enjoy this variant: 1768 \begin{verbatim} 1769 merge = Name * -> kdiff3 -o NEW CURRENTARCHOPT CURRENT1 CURRENT2 1770 \end{verbatim} 1771 1772 Ordinarily, external merge programs are only invoked when Unison is {\em 1773 not} running in batch mode. To specify an external merge program that 1774 should be used no matter the setting of the {\tt batch} flag, use the {\tt 1775 mergebatch} preference instead of {\tt merge}. 1776 1777 \begin{quote} 1778 \it 1779 Please post suggestions for other useful values of the 1780 \verb|merge| preference to the {\tt unison-users} mailing list---we'd like 1781 to give several examples here. 1782 \end{quote} 1783 1784 \finishlater{ 1785 \SUBSECTION{Communicating with a Remote Server}{server} 1786 1787 If you can mount both filesystems on the same host, then you can 1788 run with no server (note, though, that this won't be fast enough over 1789 a phone line).......... 1790 } 1791 1792 \SUBSECTION{The User Interface}{ui} 1793 1794 Both the textual and the graphical user interfaces are intended to be 1795 mostly self-explanatory. Here are just a few tricks: 1796 \begin{itemize} 1797 \item By default, when running on Unix the textual user interface will 1798 try to put the terminal into the ``raw mode'' so that it reads the input a 1799 character at a time rather than a line at a time. (This means you can 1800 type just the single keystroke ``\verb|>|'' to tell Unison to 1801 propagate a file from left to right, rather than ``\verb|>| Enter.'') 1802 1803 There are some situations, though, where this will not work --- for 1804 example, when Unison is running in a shell window inside Emacs. 1805 Setting the \verb|dumbtty| preference will force Unison to leave the 1806 terminal alone and process input a line at a time. 1807 \end{itemize} 1808 1809 \SUBSECTION{Interrupting a Synchronization}{intr} 1810 1811 It is possible to interrupt an ongoing synchronization process before it 1812 completes. Different user interfaces offer different ways of doing it. 1813 1814 \begin{tkui} 1815 In the graphical user interface the synchronization process can be interrupted 1816 before it is finished by pressing the ``Stop'' button or by closing the window. 1817 The ``Stop'' button causes the onging propagation to be stopped as quickly as 1818 possible while still doing proper cleanup. The application keeps running and a 1819 rescan can be performed or a different profile selected. Closing the window in 1820 the middle of update propagation process will exit the application immediately 1821 without doing proper cleanup; it is therefore not recommended unless the 1822 ``Stop'' button does not react quickly enough. 1823 \end{tkui} 1824 1825 \begin{textui} 1826 When not synchronizing continuously, the text interface terminates when 1827 synchronization is finished normally or due to a fatal error occurring. 1828 1829 In the text interface, to interrupt synchronization before it is finished, 1830 press ``Ctrl-C'' (or send signal \verb|SIGINT| or \verb|SIGTERM|). This will 1831 interrupt update propagation as quickly as possible but still complete proper 1832 cleanup. If the process does not stop even after pressing ``Ctrl-C'' then keep 1833 doing it repeatedly. This will bypass cleanup procedures and terminates the 1834 process forcibly (similar to \verb|SIGKILL|). Doing so may leave the archives 1835 or replicas in an inconsistent state or locked. 1836 1837 When synchronizing continuously (time interval repeat or with filesystem 1838 monitoring), interrupting with ``Ctrl-C'' or with signal \verb|SIGINT| or 1839 \verb|SIGTERM| works the same way as described above and will additionally stop 1840 the continuous process. To stop only the continuous process and let the last 1841 synchronization complete normally, send signal \verb|SIGUSR2| instead. 1842 \end{textui} 1843 1844 \SUBSECTION{Exit Code}{exit} 1845 1846 When running in the textual mode, Unison returns an exit status, which 1847 describes whether, and at which level, the synchronization was successful. 1848 The exit status could be useful when Unison is invoked from a script. 1849 Currently, there are four possible values for the exit status: 1850 \begin{itemize} 1851 \item [0]: successful synchronization; everything is up-to-date now. 1852 \item [1]: some files were skipped, but all file transfers were successful. 1853 \item [2]: non-fatal failures occurred during file transfer. 1854 \item [3]: a fatal error occurred, or the execution was interrupted. 1855 \end{itemize} 1856 The graphical interface does not return any useful information through the 1857 exit status. 1858 1859 \SUBSECTION{Path Specification}{pathspec} 1860 Several Unison preferences (e.g., \verb|ignore|/\verb|ignorenot|, 1861 \verb|follow|, \verb|sortfirst|/\verb|sortlast|, \verb|backup|, 1862 \verb|merge|, etc.) 1863 specify individual paths or sets of paths. These preferences share a 1864 common syntax based on regular-expressions. Each preference 1865 is associated with a list of path patterns; the paths specified are those 1866 that match any one of the path pattern. 1867 1868 \begin{itemize} 1869 \item Pattern preferences can be given on the command line, 1870 or, more often, stored in profiles, using the same syntax as other preferences. 1871 For example, a profile line of the form 1872 \begin{alltt} 1873 ignore = \ARG{pattern} 1874 \end{alltt} 1875 adds \ARG{pattern} to the list of patterns to be ignored. 1876 1877 \item Each \ARG{pattern} can have one of three forms. The most 1878 general form is a POSIX Extended Regular Expression introduced by the 1879 keyword \verb|Regex|. (The collating symbol, equivalence class 1880 expression, and character class expression described in 1881 \URL{https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1\_chap09.html\#tag\_09\_03\_05}{Section 9.3.5 of the POSIX specification} 1882 are not currently supported). 1883 \begin{alltt} 1884 Regex \ARG{regexp} 1885 \end{alltt} 1886 For convenience, three other styles of pattern are also recognized: 1887 \begin{alltt} 1888 Name \ARG{name} 1889 \end{alltt} 1890 matches any path in which the last component matches \ARG{name}, 1891 \begin{alltt} 1892 Path \ARG{path} 1893 \end{alltt} 1894 matches exactly the path \ARG{path}, and 1895 \begin{alltt} 1896 BelowPath \ARG{path} 1897 \end{alltt} 1898 matches the path \ARG{path} and any path below. 1899 % 1900 The \ARG{name} and \ARG{path} arguments of the latter forms of 1901 patterns are {\em not} regular expressions. Instead, 1902 standard ``globbing'' conventions can be used in \ARG{name} and 1903 \ARG{path}: 1904 \begin{itemize} 1905 \item a \verb|*| matches any sequence of characters not including \verb|/| 1906 (and not beginning with \verb|.|, when used at the beginning of a 1907 \ARG{name}) 1908 \item a \verb|?| matches any single character except \verb|/| (and leading 1909 \verb|.|) 1910 \item \verb|[xyz]| matches any character from the set $\{{\tt x}, 1911 {\tt y}, {\tt z} \}$ 1912 \item \verb|{a,bb,ccc}| matches any one of \verb|a|, \verb|bb|, or 1913 \verb|ccc|. (Be careful not to put extra spaces after the commas: 1914 these will be interpreted literally as part of the strings to be matched!) 1915 \end{itemize} 1916 \item 1917 The path separator in path patterns is always the 1918 forward-slash character ``/'' --- even when the client or server is 1919 running under Windows, where the normal separator character is a 1920 backslash. This makes it possible to use the same set of path 1921 patterns for both Unix and Windows file systems. 1922 \item 1923 A path specification may be followed by the separator ``\verb| -> |'' itself 1924 followed by a string which will be associated to the matching paths: 1925 \begin{alltt} 1926 Path \ARG{path} -> \ARG{associated string} 1927 \end{alltt} 1928 Not all pathspec preferences use these associated strings but all pathspec 1929 preferences are parsed identically and the strings may be ignored. Only the 1930 last match of the separator string on the line is used as a delimiter. Thus 1931 to allow a path specification to contain the separator string, append an 1932 associated string to it, even if it is not used. The associated string cannot 1933 contain the separator string. 1934 \end{itemize} 1935 Some examples of path patterns appear in \sectionref{ignore}{Ignoring Paths}. 1936 Associated strings are used by the preference \texttt{merge}. 1937 1938 \SUBSECTION{Ignoring Paths}{ignore} 1939 1940 Most users of Unison will find that their replicas contain lots of 1941 files that they don't ever want to synchronize --- temporary files, 1942 very large files, old stuff, architecture-specific binaries, etc. 1943 They can instruct Unison to ignore these paths using patterns 1944 introduced in \sectionref{pathspec}{Path Specification}. 1945 1946 For example, the following pattern will make Unison ignore any 1947 path containing the name \verb|CVS| or a name ending in \verb|.cmo|: 1948 \begin{verbatim} 1949 ignore = Name {CVS,*.cmo} 1950 \end{verbatim} 1951 The next pattern makes Unison ignore the path \verb|a/b|: 1952 \begin{verbatim} 1953 ignore = Path a/b 1954 \end{verbatim} 1955 Path patterns do {\em not} skip filenames beginning with \verb|.| (as Name 1956 patterns do). For example, 1957 \begin{verbatim} 1958 ignore = Path */tmp 1959 \end{verbatim} 1960 will include \verb|.foo/tmp| in the set of ignore directories, as it is a 1961 path, not a name, that is ignored. 1962 1963 The following pattern makes Unison ignore any path beginning with \verb|a/b| 1964 and ending with a name ending by \verb|.ml|. 1965 \begin{verbatim} 1966 ignore = Regex a/b/.*\.ml 1967 \end{verbatim} 1968 Note that regular expression patterns are ``anchored'': they must 1969 match the whole path, not just a substring of the path. 1970 1971 Here are a few extra points regarding the \texttt{ignore} preference. 1972 \begin{itemize} 1973 \item If a directory is ignored, all its descendants will be too. 1974 1975 \item The user interface provides some convenient commands for adding 1976 new patterns to be ignored. To ignore a particular file, select it 1977 and press ``{\tt i}''. To ignore all files with the same extension, 1978 select it and press ``{\tt E}'' (with the shift key). To ignore all 1979 files with the same name, no matter what directory they appear in, 1980 select it and press ``{\tt N}''. 1981 % 1982 These new patterns become permanent: they 1983 are immediately added to the current profile on disk. 1984 1985 \item If you use the \verb|include| directive to include a common 1986 collection of preferences in several top-level preference files, you will 1987 probably also want to set the \verb|addprefsto| preference to the name of 1988 this file. This will cause any new ignore patterns that you add from 1989 inside Unison to be appended to this file, instead of whichever top-level 1990 preference file you started Unison with. 1991 1992 \item Ignore patterns can also be specified on the command line, if 1993 you like (this is probably not very useful), using an option like 1994 \verb|-ignore 'Name temp.txt'|. 1995 1996 \item Be careful about renaming directories containing ignored files. 1997 Because Unison understands the rename as a delete plus a create, any ignored 1998 files in the directory will be lost (since they are invisible to Unison and 1999 therefore they do not get recreated in the new version of the directory). 2000 2001 \item There is also an \verb|ignorenot| preference, which specifies a set of 2002 patterns for paths that should {\em not} be ignored, even if they match an 2003 \verb|ignore| pattern. However, the interaction of these two sets of 2004 patterns can be a little tricky. Here is exactly how it works: 2005 \begin{itemize} 2006 \item Unison starts detecting updates from the root of the 2007 replicas---i.e., from the empty path. If the empty path matches an 2008 \verb|ignore| pattern and does not match an \verb|ignorenot| pattern, then 2009 the whole replica will be ignored. (For this reason, it is not a good 2010 idea to include \verb|Name *| as an \verb|ignore| pattern. If you want to 2011 ignore everything except a certain set of files, use \verb|Name ?*|.) 2012 \item If the root is a directory, Unison continues looking for updates in 2013 all the immediate children of the root. Again, if the name of some child matches an 2014 \verb|ignore| pattern and does not match an \verb|ignorenot| pattern, then 2015 this whole path {\em including everything below it} will be ignored. 2016 \item If any of the non-ignored children are directories, then the process 2017 continues recursively. 2018 \end{itemize} 2019 \end{itemize} 2020 2021 \SUBSECTION{Symbolic Links}{symlinks} 2022 2023 Ordinarily, Unison treats symbolic links in Unix replicas as 2024 ``opaque'': it considers the contents of the link to be just the 2025 string specifying where the link points, and it will propagate changes in 2026 this string to the other replica. 2027 2028 It is sometimes useful to treat a symbolic link ``transparently,'' 2029 acting as though whatever it points to were physically {\em in} the 2030 replica at the point where the symbolic link appears. To tell Unison 2031 to treat a link in this manner, add a line of the form 2032 \begin{alltt} 2033 follow = \ARG{pathspec} 2034 \end{alltt} 2035 to the profile, where \ARG{pathspec} is a path pattern as described in 2036 \sectionref{pathspec}{Path Specification}. 2037 2038 Not all Windows versions and file systems support symbolic links; Unison will 2039 refuse to propagate an opaque symbolic link from Unix to Windows and flag the 2040 path as erroneous if the support or privileges are lacking on the Windows side. 2041 When a Unix replica is to be synchronized with such Windows system, all symbolic 2042 links should match either an \verb|ignore| pattern or a \verb|follow| pattern. 2043 2044 You may need to acquire extra privileges to create symbolic links under 2045 Windows. By default, this is only allowed for administrators. Unison may not 2046 be able to automatically detect support for symbolic links under Windows. In 2047 that case, set the preference {\tt links} to {\tt true} explicitly. 2048 2049 2050 \SUBSECTION{Permissions}{perms} 2051 2052 Synchronizing the permission bits of files is slightly tricky when two 2053 different filesystems are involved (e.g., when synchronizing a Windows 2054 client and a Unix server). In detail, here's how it works: 2055 \begin{itemize} 2056 \item When the permission bits of an existing file or directory are 2057 changed, the values of those bits that make sense on {\em both} 2058 operating systems will be propagated to the other replica. The other 2059 bits will not be changed. 2060 \item When a newly created file is propagated to a remote replica, the 2061 permission bits that make sense in both operating systems are also 2062 propagated. The values of the other bits are set to default values 2063 (they are taken from the current umask, if the receiving host is a 2064 Unix system). 2065 \item For security reasons, the Unix \verb|setuid| and \verb|setgid| 2066 bits are not propagated. 2067 \item The Unix owner and group ids can be propagated (see \verb|owner| 2068 and \verb|group| preferences) by mapping names or by numeric ids (see 2069 \verb|numericids| preference). 2070 \end{itemize} 2071 2072 2073 \SUBSECTION{Access Control Lists - ACLs}{acls} 2074 2075 Unison allows synchronizing access control lists (ACLs) on platforms 2076 and filesystems that support them. In general, synchronization makes 2077 sense only in case both replicas support the same type of ACLs and 2078 recognize same users and groups. In some cases you may be able to 2079 go beyond that and synchronize ACLs to a replica that couldn't fully 2080 use them---this may be be useful for the purpose of preserving ACLs. 2081 2082 If one of the replicas does not support any type of ACLs then 2083 Unison will not attempt ACL synchronization. If the other replica 2084 does support ACLs then those will remain intact. 2085 2086 If both replicas support ACLs of any supported type then you can 2087 request Unison to try ACL synchronization (\verb|acl| preference). 2088 Success of synchronization depends on permissions of the owner and 2089 group of Unison process (Unison must have permissions to set ACL) 2090 and the compatibility of ACL types on both replicas. 2091 2092 An ACL is propagated as a single unit, with all ACEs. There is no 2093 merging of ACEs from the replicas. 2094 2095 {\em Caveat}: ACE inheritance may in certain scenarios cause synchronization 2096 inconsistencies. In Windows, only explicit ACEs are synchronized; inherited 2097 ACEs are not actively synchronized, but Windows will propagate ACEs from parent 2098 directories (unless inheritance is explicitly prevented on a file or a 2099 directory---this prevention is also synchronized). Due to inheritance, the 2100 ultimately effective ACL may be different, or provide different access, even 2101 after synchronization. 2102 2103 Unison currently supports the following platforms and ACL types: 2104 \begin{itemize} 2105 \item Windows (Windows XP SP2 and later) 2106 \begin{itemize} 2107 \item NTFS ACL (discrete ACL (DACL) only) 2108 \end{itemize} 2109 \item Solaris, OpenSolaris and illumos-based OS (OpenIndiana, SmartOS, 2110 OmniOS, etc.) 2111 \begin{itemize} 2112 \item NFSv4 ACL (ZFS ACL) 2113 \item POSIX-draft ACL 2114 \item Some NFSv4 ACL (ZFS ACL) cross-synchronization with 2115 POSIX-draft ACL 2116 \item Full cross-synchronization with other platforms that support 2117 NFSv4 ACLs; limited cross-synchronization with POSIX-draft ACLs 2118 \end{itemize} 2119 \item FreeBSD, NetBSD 2120 \begin{itemize} 2121 \item NFSv4 ACL (ZFS ACL) 2122 \item Limited POSIX-draft ACL (access ACL only; not default ACL) 2123 \item Full cross-synchronization with other platforms that support 2124 NFSv4 ACLs 2125 \end{itemize} 2126 \item Darwin (macOS) 2127 \begin{itemize} 2128 \item Extended ACL 2129 \end{itemize} 2130 \end{itemize} 2131 Not all filesystems on the listed platforms support all ACL types 2132 (or any ACLs at all). 2133 2134 Synchronizing POSIX ACLs on Linux is not supported directly. However, it is 2135 possible to synchronize these ACLs with another Linux system by synchronizing 2136 extended attributes (xattrs) instead, because POSIX ACLs are stored as xattrs 2137 by Linux. This is disabled by default (see \sectionref{xattrs}{Extended 2138 Attributes - xattrs}). A simple way to enable syncing POSIX ACLs on Linux is 2139 to enable the preference \verb|xattrs| and add a preference 2140 \verb|xattrignorenot| with a value \texttt{Path !system.posix\_acl\_*}. The 2141 \verb|*| will be expanded to include both \verb|posix_acl_access| and 2142 \verb|posix_acl_default| attributes -- if you only want to sync either one, 2143 just remove the \verb|*| and type out the attribute name in full. If you want 2144 to prevent other xattrs from being synced then add an \verb|xattrignore| with a 2145 value \texttt{Path *} (value \texttt{Regex .*} will also work). 2146 2147 2148 \SUBSECTION{Extended Attributes - xattrs}{xattrs} 2149 2150 Unison allows synchronizing extended attributes on platforms and 2151 filesystems that support them. System attributes are not synchronized. 2152 What exactly is considered a system attribute is platform-dependent. 2153 Synchronization is possible cross-platform, but see caveats below. 2154 2155 If one of the replicas does not support extended attributes then 2156 Unison will not attempt attribute synchronization. If the other 2157 replica does support extended attributes then those will remain intact. 2158 2159 If both replicas support extended attributes then you can request 2160 Unison to try attribute synchronization (\verb|xattrs| preference). 2161 Extended attributes from both replicas will not be merged, all extended 2162 attributes are propagated as a set from one replica to another. 2163 2164 Unison currently supports extended attributes on the following platforms: 2165 \begin{itemize} 2166 \item {\em Linux} 2167 Attributes in user, trusted and security namespaces. Synchronization of 2168 the latter two namespaces depends on \verb|unison| process privileges 2169 and is disabled by default. To sync one or more attributes in the security 2170 namespace, for example, you can set the preference 2171 \verb|xattrignorenot| to \verb|Path !security.*| (for all) or to 2172 \verb|Path !security.selinux| (for one specific attribute). 2173 Attributes in system namespace are not synchronized, with the exception of 2174 \verb|system.posix_acl_default| and \verb|system.posix_acl_access| (also 2175 disabled by default). 2176 \item {\em Solaris, OpenSolaris and illumos-based OS (OpenIndiana, SmartOS, 2177 OmniOS, etc.)} 2178 \item {\em FreeBSD, NetBSD} 2179 Attributes in user namespace. 2180 \item {\em Darwin (macOS)} 2181 \end{itemize} 2182 Not all filesystems on the listed platforms may support extended attributes. 2183 2184 \noindent {\it Caveats:} 2185 \begin{itemize} 2186 \item Some platforms and file systems support very large extended attribute 2187 values. Unison synchronizes only up to 16 MB of each attribute value. 2188 \item Attributes are synchronized as simple name-value pairs. More complex 2189 extended attribute concepts supported by some platforms are not synchronized. 2190 \item On Linux, attribute names always have a fully qualified form 2191 (\texttt{namespace.attribute}). Other platforms do not have the same constraint. 2192 The consequence of this is that Unison will sync the attribute names on Linux 2193 as follows: an \verb|!| is prepended to the namespace name, except for the 2194 \verb|user| namespace; the \verb|user.| prefix is stripped from attribute names 2195 instead. This allows syncing extended attributes from Linux to other platforms. 2196 These transformations are reversed when syncing {\em to} Linux, resulting in 2197 correct fully qualified attribute names. 2198 The \verb|xattrignore| and \verb|xattrignorenot| preferences work on the 2199 transformed attribute names. This means that any patterns for the user 2200 namespace must be specified without the \verb|user.| prefix and any patterns 2201 intended for other namespaces must begin with an \verb|!|. 2202 \end{itemize} 2203 2204 The \verb|xattrignore| preference can be used to filter the names of extended 2205 attributes that will be synchronized. The most useful ignore patterns can 2206 be constructed with the \verb|Path| form (where shell wildcards \verb|*| and 2207 \verb|?| are supported) and with the \verb|Regex| form. The 2208 \verb|xattrignorenot| preference can be used to override \verb|xattrignore|. 2209 2210 Disabling the security and trusted namespaces on Linux is achieved by setting 2211 a default \verb|xattrignore| pattern of 2212 \texttt{Regex !(security|trusted)[.].*}. 2213 Disabling the syncing of attributes used to store POSIX ACL on Linux is 2214 achieved by setting a default \verb|xattrignore| pattern of 2215 \texttt{Path !system.posix\_acl\_*}. 2216 2217 2218 \SUBSECTION{Cross-Platform Synchronization}{crossplatform} 2219 2220 If you use Unison to synchronize files between Windows and Unix 2221 systems, there are a few special issues to be aware of. 2222 2223 \textbf{Case conflicts.} In Unix, filenames are case sensitive: 2224 \texttt{foo} and \texttt{FOO} can refer to different files. In 2225 Windows, on the other hand, filenames are not case sensitive: 2226 \texttt{foo} and \texttt{FOO} can only refer to the same file. This 2227 means that a Unix \texttt{foo} and \texttt{FOO} cannot be synchronized 2228 onto a Windows system --- Windows won't allow two different files to 2229 have the ``same'' name. Unison detects this situation for you, and 2230 reports that it cannot synchronize the files. 2231 2232 You can deal with a case conflict in a couple of ways. If you need to 2233 have both files on the Windows system, your only choice is to rename 2234 one of the Unix files to avoid the case conflict, and re-synchronize. 2235 If you don't need the files on the Windows system, you can simply 2236 disregard Unison's warning message, and go ahead with the 2237 synchronization; Unison won't touch those files. If you don't want to 2238 see the warning on each synchronization, you can tell Unison to ignore 2239 the files (see \sectionref{ignore}{Ignoring Paths}). 2240 2241 \textbf{Illegal filenames.} Unix allows some filenames that are 2242 illegal in Windows. For example, colons (`:') are not allowed in 2243 Windows filenames, but they are legal in Unix filenames. This means 2244 that a Unix file \texttt{foo:bar} can't be synchronized to a Windows 2245 system. As with case conflicts, Unison detects this situation for 2246 you, and you have the same options: you can either rename the Unix 2247 file and re-synchronize, or you can ignore it. 2248 2249 2250 \SUBSECTION{Slow Links}{speed} 2251 2252 Unison is built to run well even over relatively slow links such as 2253 modems and DSL connections. 2254 2255 Unison uses the ``rsync protocol'' designed by Andrew Tridgell and Paul 2256 Mackerras to greatly speed up transfers of large files in which only 2257 small changes have been made. More information about the rsync protocol 2258 can be found at the rsync web site (\ONEURL{http://samba.anu.edu.au/rsync/}). 2259 2260 If you are using Unison with {\tt ssh}, you may get some speed 2261 improvement by enabling {\tt ssh}'s compression feature. Do this by 2262 adding the option ``{\tt -sshargs -C}'' to the command line or ``{\tt 2263 sshargs = -C}'' to your profile. 2264 2265 2266 \SUBSECTION{Making Unison Faster on Large Files}{speeding} 2267 2268 Unison's built-in implementation of the rsync algorithm makes transferring 2269 updates to existing files pretty fast. However, for whole-file copies of 2270 newly created files, the built-in transfer method is not highly optimized. 2271 Also, if Unison is interrupted in the middle of transferring a large file, 2272 it will attempt to retransfer the whole thing on the next run. 2273 2274 These shortcomings can be addressed with a little extra work by telling 2275 Unison to use an external file copying utility for whole-file transfers. 2276 The recommended one is the standalone {\tt rsync} tool, which is available 2277 by default on most Unix systems and can easily be installed on Windows 2278 systems using Cygwin. 2279 2280 If you have {\tt rsync} installed on both hosts, you can make Unison use it 2281 simply by setting the {\tt copythreshold} flag to something non-negative. 2282 If you set it to 0, Unison will use the external copy utility for {\em all} 2283 whole-file transfers. (This is probably slower than letting Unison copy 2284 small files by itself, but can be useful for testing.) If you set it to a 2285 larger value, Unison will use the external utility for all files larger than 2286 this size (which is given in kilobytes, so setting it to 1000 will cause the 2287 external tool to be used for all transfers larger than a megabyte). 2288 2289 If you want to use a different external copy utility, set both the {\tt 2290 copyprog} and {\tt copyprogrest} preferences---the former is used for 2291 the first transfer of a file, while the latter is used when Unison sees a 2292 partially transferred temp file on the receiving host. Be careful here: 2293 Your external tool needs to be instructed to copy files in place (otherwise 2294 if the transfer is interrupted Unison will not notice that some of the data 2295 has already been transferred, the next time it tries). The default values 2296 are: 2297 \begin{verbatim} 2298 copyprog = rsync --inplace --compress 2299 copyprogrest = rsync --partial --inplace --compress 2300 \end{verbatim} 2301 2302 If a {\em directory} transfer is interrupted, the next run of Unison will 2303 automatically skip any files that were completely transferred before the 2304 interruption. (This behavior is always on: it does not depend on the 2305 setting of the {\tt copythreshold} preference.) Note, though, that the new 2306 directory will not appear in the destination filesystem until everything has 2307 been transferred---partially transferred directories are kept in a temporary 2308 location (with names like {\tt .unison.DIRNAME....}) until the transfer is 2309 complete. 2310 2311 2312 \SUBSECTION{Fast Update Detection}{fastcheck} 2313 2314 If your replicas are large and at least one of them is on a Windows 2315 system, you may find that Unison's default method for detecting changes 2316 (which involves scanning the full contents of every file on every 2317 sync---the only completely safe way to do it under Windows) is too slow. 2318 Unison provides a preference {\tt fastcheck} that, when set to 2319 \verb|true|, causes it to use file creation times as 'pseudo inode 2320 numbers' when scanning replicas for updates, instead of reading the full 2321 contents of every file. 2322 2323 When \verb|fastcheck| is set to \verb|no|, 2324 Unison will perform slow checking---re-scanning the contents of each file 2325 on each synchronization---on all replicas. When \verb|fastcheck| is set 2326 to \verb|default| (which, naturally, is the default), Unison will use 2327 fast checks on Unix replicas and slow checks on Windows replicas. 2328 2329 This strategy may cause Unison to miss propagating an update if the 2330 modification time and length of the file are both unchanged 2331 by the update. 2332 However, Unison will never {\em overwrite} such an update with a change 2333 from the other replica, since it always does a safe check for updates 2334 just before propagating a change. Thus, it is reasonable to use this 2335 switch most of the time and occasionally run Unison once with {\tt 2336 fastcheck} set to \verb|no|, if you are worried that Unison may have 2337 overlooked an update. 2338 2339 Fastcheck is (always) automatically disabled for files with extension 2340 \verb|.xls| or \verb|.mpp|, to prevent Unison from being confused by the 2341 habits of certain programs (Excel, in particular) of updating files without 2342 changing their modification times. 2343 2344 \SUBSECTION{Mount Points and Removable Media}{mountpoints} 2345 2346 Using Unison removable media such as USB drives can be dangerous unless you 2347 are careful. If you synchronize a directory that is stored on removable 2348 media when the media is not present, it will look to Unison as though the 2349 whole directory has been deleted, and it will proceed to delete the 2350 directory from the other replica---probably not what you want! 2351 2352 To prevent accidents, Unison provides a preference called 2353 \verb|mountpoint|. Including a line like 2354 \begin{verbatim} 2355 mountpoint = foo 2356 \end{verbatim} 2357 in your preference file will cause Unison to check, after it finishes 2358 detecting updates, that something actually exists at the path 2359 \verb|foo| on both replicas; if it does not, the Unison run will 2360 abort. 2361 2362 \appendix 2363 2364 \finishlater{ 2365 \SECTION{Other Synchronizers}{other}{other} 2366 2367 See also: 2368 2369 D. Duchamp 2370 A Toolkit Approach to Partially Disconnected Operation 2371 Proc. USENIX 1997 Ann. Technical Conf. 2372 USENIX, Anaheim CA, pp. 305-318, January 1997 2373 \ONEURL{https://www.usenix.org/conference/usenix-1997-annual-technical-conference/toolkit-approach-partially-connected-computing} 2374 } 2375 2376 \finishlater{ 2377 \SECTION{TODO}{todo}{ } 2378 2379 Things to write about: 2380 \begin{itemize} 2381 \item When started in 'socket server' mode, Unison prints 'server started' on 2382 stderr when it is ready to accept connections. 2383 (This may be useful for scripts that want to tell when a socket-mode server 2384 has finished initialization.) 2385 \item {\tt DANGER.README}. 2386 \end{itemize} 2387 } 2388 2389 \finishlater{ 2390 Things to write about later: 2391 \begin{itemize} 2392 \item Document different reporting of file status when no archives 2393 were found. 2394 \item Document buttons in graphical UI 2395 \end{itemize} 2396 } 2397 2398 \iftextversion 2399 \SECTION{Junk}{ }{ } 2400 \fi 2401 2402 \ifhevea\begin{rawhtml}</div>\end{rawhtml}\fi 2403 2404 \end{document}