----- Original Message -----
From: "Bob S" <911@sanctum.com>
To:
Hi SuSE people,
1 When I backup a direcory (home for instance) rsync copies everything UNDER that folder. How can I make it keep the title directory? "home"
2 How do YOU restore. A whole directory or just a few files for instance. Does it overwrite?
This is all covered in "man rsync" There are even sample rsync commands for common usage like that. Before each following example run this also: export USER=thisbox RSYNC_PASSWORD=thisboxpass To copy /home from thisbox to otherbox, run on thisbox: rsync -avz --del /home otherbox::thisbox To restore /home from otherbox to thisbox, run on thisbox: rsync -avz --del otherbox::thisbox/home / To restore just one user from the backup: rsync -avz --del otherbox::thisbox/home/frank /home To restore just one file from the backup: rsync -avz otherbox::thisbox/home/frank/somefile /home/frank These examples are correct but they are not correct all on their own. They are only correct in concert with several other things being set a certain way. But you don't necessarily have to set those other things up just that way, that would just mean that there would be other coands that were correct in that other context. It was necessary to assume several things, because, we can't answer the questions to cover every possible case except by writing the equivalent of the man page, which would be stupid since it's already been written. So these examples assume: * you have "otherbox" defined in /etc/hosts on thisbox 172.0.0.2 thisbox 192.168.0.4 otherbox.lan otherbox * you have the native rsync service running on otherbox chkconfig rsyncd on rcrsyncd start * you have a user & password defined in /etc/rsyncd.secrets on otherbox thisbox:thisboxpass * you have a module [thisbox] defined in /etc/rsyncd.conf on otherbox [thisbox] path = /path/to/backups/thisbox auth users = thisbox read only = false numeric ids = false munge symlinks = false use chroot = true * you have restarted rsyncd on otherbox after making any changes to rsyncd.conf or .secrets on otherbox rcrsyncd restart * you will want to place the backup commands into a cron job, and thus don't want commands that are affected by what user you are currently logged in as, since cron runs as root. * similarly, you will want to restore onto a brand new install and will be running as root but don't want to define a user "root" in rsyncd.secrets on otherbox. Not that that would be harmful really. It just makes more sense to create a module and user for each machine that will be storing backups there, named after the machine. Note: rsync users have nothing slightly whatever to do with system users except that client-side rsync will default to using your current login id as the username when contacting the rsync server, unless you specify a user with the USER variable or by using the user@host::module/path syntax. Both the backup and the restore operation will clone the entire /home directory and all contents exactly. If you delete a dir from /home, and then run a backup, it will be deleted from the backup. If you added a dir to /home since the last backup and then perform a restore, the new dir will be deleted. As for overwriting, yes it overwrites. Files are not so much copied as replicated. The target file is made to be the same as the source file. Only in some cases does this mean copying/transferring the whole file. If you are placing the backup command into a cron job, remove v from -avz, leaving -az If you are restoring for the first time onto a new empty install, you can go a little faster by adding -W and --inplace. so, "-avzW --del --inplace" Removing -v will speed it up a lot more, you just don't get to watch the files scroll by. If you don't want the deletions, remove --del, though I don't recommend that. It can be just as important to delete a file as to create one. To me the only sane form of copy or backup is to preserve and restore the entire state exactly, and that means deleting files that were deleted. Performing routine rsync backups & restores without --del is just going to gradually accumulate a big mess of cruft. There are other tools for handling the need to provide history, which is the sane way deal with getting a file back that you deleted. (snapshots, roll-your-own tar scripts, and just about every backup program out there, hint: rsync is not a backup program) This is all just what's convenient and sane for me, which is perhaps only true for me and/or only in the context of other factors particular to my operations. There are many many ways to use rsync because it has many features to cover many situations. If any of this doesn't fit in with your plans, well, that is why the man page exists to describe everything rsync can do. -- Brian K. White brian@aljex.com http://www.myspace.com/KEYofR +++++[>+++[>+++++>+++++++<<-]<-]>>+.>.+++++.+++++++.-.[>+<---]>++. filePro BBx Linux SCO FreeBSD #callahans Satriani Filk! -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org