I. Specifying transport (Text here was obsoleted) II. Specifying source directory If the source is a directory, a trailing / means "the contents of the directory", NOT the directory itself. Alternatively, no trailing slash means "the directory itself plus its contents". III. Specifying destination directory Trailing / on target directories have no effect. It makes no difference whether you use it or not. IV. Preserving paths When using the -a switch, by default, specified leading paths are not preserved, only internal paths are. To additionally preserve the specified leading paths, use the -R switch. Note that it is "useful" to be able to copy a bunch of stuff from various places into the same destination directory. That's the default behavior. But since we are interested in "mirroring" stuff between servers, we will sometimes use the -R switch (and --delete). When you supply more than one source, you will sometimes want to use -R. V. Don't forget to use the -H switch to preserve hard links, and --delete to remove old stuff in the destination directory. Note that the --delete stuff will not remove everything in the dest directory which does not exist in the corresponding place on the source machine, but only stuff underneath the dest directory corresponding to the source directories that you specify. If we gave --delete in this example, rsync --delete -RavHe ssh1 dir1/ file2 path/to/dir3 path/to/file4 otherhost:/destination/dir rsync could only remove things from the branches otherhost:/destination/dir/dir1 otherhost:/destination/dir/path/to/dir3 So, the rsync command really says to sync-up only branches dir1, file2, dir3, and file4, not everything at otherhost:/destination/dir. SEQUENCE: Regardless of how many source files/branches you specify, the file/dir list is sent in completely alphabetical order. Digits then caps then lower-case (probably ASCII ordering). !Verbose mode (-v) prints the file it is "currently working on". Therefore, until the program completes, the last filename listed (at any time) has not finished transferring yet. ! While copying a file, it makes a file in the dest directory named .ORIG_FILENAME.something. This file is "RENAMED" to the final name after the xfer is completed. In the case of a file "update", the .ORIG.something is created in its entirety and the original inode is removed before the .ORIG.something is renamed. (I have verified all of this, including watching the inodes). INTERRUPTION If interrupted with SIGINT, SIGTERM, or SIGHUP the .ORIG.something file will be removed. Also works via Ctrl-C. I have not tested with SIGKILL. INCLUSION/EXCLUSION PATHS Unlike Ant patterns, everything is included by default. Candidates (based on source path specification recursion AND PREVIOUSLY ***APPLIED*** PARENT EXCLUSIONS!) are matched against includes/excludes in turn, and are included or excluded based on the very first match. The only non-intuitive aspect of this is, an exclude of a parent dir can prevent patterns for descendants from ever getting candidates. For example, "--exclude '/*'" IN ANY POSITION prevents ALL copying. The tricky thing there is that for recursive runs, ancestor directories will always be tested against before descendant directories. Order of the includes/excludes is only used when comparing paths of the same length (I'm talking number of elements here, not string lengths). * and ** are like Ant's. (As a consequence, use "dir/" to exclude all dirs name "dir" and all contents; but use "dir/**" to copy just the "dir" directories with no contents). Given patterns are matched against paths as they appear with a -v operation. (N.b., this is NOT HOW THEY ARE SPECIFIED, since with -a they will be absolute to the source directory you specify). So, since rsync -aH /mnt/ /mnt/tmp/mnt Prints file paths like file/path/relative/to/mnt Your exclusion paths must be written as if /mnt were the ROOT. I.e., /mnt -> / , "/x" -> "/mnt/x", "x" -> "/mnt/**/x" As the examples show, these paths must begin with / or they will match any portion of the test paths). N.b. that, unlike tar matching, if you give source of ., the paths will not include the useless leading "./", and patterns to match the beginning will start with "/relpath" (or "relpath" to also match later). pat*ern/ Will exclude these directories and everything below them. pat*ern/** Will include the matching directories but nothing below them. Sample to xfer everything under /a except for branch /a/b/c1 branch. - /a/b/c1 + /a/ + /a/** - /** List all of the anonymous rsync modules: rsync host.name:: --compare-dest=DIR (relative to dest dir if relative) effectively adds a new source directory (on the target server), just like you would want. --link-dest=DIR works exactly the same, sharing hard links where possible. I often want to back up just the directories themselves, with no contents. To do this, use "--exclude 'dir/path/*'". Surprisingly, the * matches .* too. Mose useful args. Know these. -a -P -R (Relative, note capital R, since 'r' means "recursive") -x (same as cp's -x) -H -e Can be a multi-token command including nested quotes. See SSH options below for a critical use case. -v --numeric-ids --compare-dest= (see right above) -link-dest= (see right above) -b + --backup-dir= -b (without --backup-dir, writes *~ files on receiving side, which you can then manually examine). -f ("-f '- pattern'" == "--exclude=pattern"; "-f '+ pattern'" == "--inc...) (Good to know that --force generally isn't needed). -W is default for local copies, and I guess circumvents checksumming. Rsync will create ONE level of directory (at least if destination is specified like /$) at the destination, but not more. /$ is significant with destinations. It won't create dest as file if dest ends with /. Rsync with only 1 src+dest just does a "ls". There is no way to display just 1 character per file xmitted. There is a switch to specify output-format-per-file, but a newline is always appended. To dup just directories: rsync -avHf '+ **/' -f '- *' To copy a whole disk rsync -axXSAH src/mt/pt/ dest/mt/pt Continuing/Resuming: --partial switch, which is included in -P allows for continuation by not cleaning up incompleted data files. SSH options: -e honors nested quotes. Great! rsync -e 'openssh -o "StrictHostKeyChecking no"'