rsync works great - the first time

I have been learning about rsync as a tool to backup my entire drive onto an external drive (and then with the bless command, making it bootable). I finally got it to work! I can boot into External and everything works just like my main drive.

Now the problem. When I do it again, it is supposed to just replace files I've changed and delete files that have been deleted on the source. Instead, the exact same command now makes a whole new copy of the source inside the external drive, inside a /Volumes folder in an External folder.

Here is my rsync command:
sudo /usr/bin/rsync -avSE --delete --stats --exclude-from /Applications/Utilities/rsync_excludes.txt / /Volumes/External/

I've tried it with and without the trailing slash after the destination (External); it doesn't seem to make a difference.

Can anyone tell me why this is happening?

Thanks,
Jim

iBook 600, Mac OS X (10.4.8)

Posted on Oct 22, 2006 7:35 PM

Reply
17 replies

Oct 24, 2006 7:10 AM in response to Michael Bradshaw

Mike, I think you (and Gary) are right, excluding /Volumes or /Volumes/External should prevent it. I was starting to wonder about that too.

Here's another thought. I had left the -x option out because I didn't understand it. I still don't, but now I suspect it is designed to avoid exactly this problem. Here is the man entry:

***************************
-x, --one-file-system
This tells rsync to avoid crossing a filesystem boundary when recursing. This does not limit the user's ability to specify items to copy from multiple filesystems, just rsync's recursion through the hierarchy of each directory that the user specified, and also the analogous recursion on the receiving side during deletion. Also keep in mind that rsync treats a "bind" mount to the same device as being on the same filesystem.
If this option is repeated, rsync omits all mount-point directories from the copy. Otherwise, it includes an empty directory at each mount-point it encounters (using the attributes of the mounted directory because those of the underlying mount-point directory are inaccessible).

If rsync has been told to collapse symlinks (via --copy-links or --copy-unsafe-links), a symlink to a directory on another device is treated like a mount-point. Symlinks to non-directories are unaffected by this option.
************************

I don't get all the bind mount and mount-point lingo, but does this sound like what I need? I'll start from scratch a little later today with that option if I get any positive feedback on it and see how it goes.

Incidentally, Gary, I have no idea what the stuff in /dev is, but I had an early problem with rsync getting hung up (went into a loop) on /dev/fd/3 and I read somewhere I could add /dev/fd to my exclude file without harm, and that worked. If this whole thing works I will report the final rsync command and exclude file in full for benefit of any others.

Thanks!
Jim

Oct 24, 2006 8:06 AM in response to Jimbo

Hi Jim,
Yes, the "-x" option should do what you want and of course it's more elegant. It will also take care of the /dev problem and that was probably a problem, whether you knew it or not. Excluding /dev/fd is necessary but insufficient. It wasn't caught in an infinite loop in there, it was waiting for STDOUT to send an EOF or something like that.

"Files" in /dev aren't files in the classic sense. It's possibly the ultimate manifestation of the UNIX credo that "everything is a file." It's a "virtual filesystem" in which files "represent" physical devices hooked to the computer. That way you can use file read and write operations to communicate with the devices. On some systems you can send raw streams to printer that way. All of your disk partitions are represented that way and that's where another infinite loop could come in. Therefore, never ever read or write to /dev unless you are performing a well-understood manipulation of the device tree.

Fortunately the device tree is a separate filesystem from / so as I said, the "--one-file-system" option will cover you there too. By the way, the UNIX "find" command supports the same option in the same way.
--
Gary
~~~~
pessimist:
A man who spends all his time worrying about how he
can keep the wolf from the door.

optimist:
A man who refuses to see the wolf until he seizes
the seat of his pants.

opportunist:
A man who invites the wolf in and appears the next
day in a fur coat.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

rsync works great - the first time

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.