Rsync, however is terribly overfeatured and has more options and modes than anyone can keep straight. These are simply my notes about how to use the few things that I find a regular need to use. I rarely use it across the network from one machine to another, although it is good to know that it can do such things and that it even supports its own protocol for this kind of thing (when I have done this, I just use an ssh connection).
rsync --dry-run -av /old/ /new rsync -n -av /old/ /new
rsync -av -e "ssh -p 4223" --exclude-from=crater_exclude [email protected]:/d0/pilot /u9
Here is a simpler example of the --exclude-from file option. It allows you to specify files (and/or directories) relative to the source path that should be excluded from the copy. You use your favorite editor to create a file (pathnames relative to the source directory) that should be excluded from the sync.
For example if you were doing the following:
rsync -av --exclude-from=exfile /backuproot/ /Then the exfile might look like (along with other things)
dev proc
My typical use of rsync looks like one of the following commands:
rsync -av /home/wally /archive rsync -av /home/wally/ /archive/wallyThe difference between these two commands has bitten me many times and is one of my main motivations for writing this little note.
rsync -av /home/wally /archiveThe above command will create (if it does not exist already) the directory /archive/wally and recursively copy everything into there. This is just the thing if you are doing a first time copy. This is usually not what I want and makes me angry by producing a new directory.
rsync -av /home/wally/ /archive/wallyThis command will NOT create the wally directory inside /archive, but expects the source and destination directories to be "equivalent". This is just the thing if you want to make a prior copy up to date, and usually matches how I think about things.
Also take note of the -av switch. The v option just says to be verbose and tell about every file that gets transferred. The a option is a composite option that is the same as -rlptgoD which is in general "just what I want". When I forget the -av switch, I get the confusing message.
skipping directory wally
You also may want to consider adding the -u (update) switch. This tells rsync to skip files that have newer timestamps at the destination.
--bwlimit=2000 says to bandwidth limit what goes on in units of kb/second, which is nice for gigantic transfers over shared links.
--delete says to delete files on the receiver that are not on the source. I do not routinely do this, but it is the thing to do when you do something like rearrange the directory structure on the source.
Consider the -u option (and thus using -auv instead of -av). This says to avoid overwriting a destination file with a newer modification time than the source, the idea being that the files are different, but that the destination file is more recent and we don't want to overwrite it with an old copy from another directory or machine. In general the right thing. As an example, I use the following command to keep a backup copy of all my photos on a good sized external USB hard drive:
rsync -auv /home/Camera/photos /media/disk
rsync -auv -e ssh remotehost:/home/wally /local/archive rsync -auv -e ssh /local/archive/wally remotehost:/homeAll the same screwy business of the trailing slash and creating new directories mentioned above still applies.
Adventures in Computing / [email protected]