[opensuse] Two simple rsync questions
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? Bob S -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
Bob S wrote:
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?
Bob S
What command are you using to run rsync? Sudhir -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
On Tue, 2008-07-08 at 05:39 +0100, Sudhir wrote:
Bob S wrote:
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"
I deduce from your question that you want the copies of directory home to appear under target_dir/home ?? The same way as in copy, I suppose.. ;) cp -r home/* target_dir/home/
2 How do YOU restore. A whole directory or just a few files for instance.a Does it overwrite?
I think that by defaut rsync looks at the modification times of the files. If you rsync from A to B it overwrites only the files in B that are older than the same files in A. If you want to synchronize two directories (or make backups) only of certain type of files, you might want to try this: http://www.fyslab.hut.fi/~sri/syncsdirs_example.py .. the include/exclude rules in rsync are quite tricky. (if you are not copying to a remote machine, just put whereto="") Cheers, Sampsa
Bob S
What command are you using to run rsync?
Sudhir
-- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
Bob S wrote:
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"
You will often get better answers if you provide more detailed information. In this case, it would be useful to know the exact command you are currently using, because without it we have to guess what your problem is. If you read the rsync man page carefully, you will see that there is a difference between: rsync -a foo:src/bar/ /data/tmp and rsync -a foo:src/bar /data/tmp that results in exactly the difference you want. Perhaps this is the source of your problem? Cheers, Dave -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
On Tuesday 08 July 2008 05:04:12 am Dave Howorth wrote:
Bob S wrote:
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"
Thanks for replying Sudhir, Sampsa, Dave
You will often get better answers if you provide more detailed information. In this case, it would be useful to know the exact command you are currently using, because without it we have to guess what your problem is.
If you read the rsync man page carefully, you will see that there is a difference between:
That is the keyword, carefully intently, and confusing.
rsync -a foo:src/bar/ /data/tmp
and
rsync -a foo:src/bar /data/tmp
that results in exactly the difference you want. Perhaps this is the source of your problem?
Yes, I now see the difference. Thanks. I will try it later. Bob S -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
Bob S wrote:
That is the keyword, carefully intently, and confusing.
I agree that rsync can be confusing, especially if you're new to it or use it rarely. It's worth persisting though, because it's a very useful program. It's also worth noting that it's very easy to test. Just make a 'source' directory and a 'dest' directory, put a few appropriate files and subdirectories in them and run your rsync command line against them. Cheers, Dave -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 The Wednesday 2008-07-09 at 10:01 +0100, Dave Howorth wrote:
I agree that rsync can be confusing, especially if you're new to it or use it rarely. It's worth persisting though, because it's a very useful program. It's also worth noting that it's very easy to test. Just make a 'source' directory and a 'dest' directory, put a few appropriate files and subdirectories in them and run your rsync command line against them.
Absolutely. You can also halt it in mid work if you have to, and continue later: the en result will be correct without having to copy everything again. It is a very interesting and usefull program. - -- Cheers, Carlos E. R. -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.4-svn0 (GNU/Linux) iD8DBQFIdIkgtTMYHG2NR9URAnUGAJwLj0E5ASkVG9ZR+ceH8hRhszC/bwCfeHgc lIEOxlaEuM3aOFX9FBcJCXc= =GcIX -----END PGP SIGNATURE----- -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
----- 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
On Tuesday 08 July 2008 06:35:10 am Brian K. White wrote:
----- Original Message ----- From: "Bob S" <911@sanctum.com> To:
Sent: Monday, July 07, 2008 8:13 PM Subject: [opensuse] Two simple rsync questions 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.
<snip instructions> Wow Brian you sound like the man page, but lots more instructive. I read the man page several times and found it confusing for somebody who has never used the program. info man did give some examples.
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.
I am simply preserving files and their structure to a USB hard drive. Some of those instructions sound a little scary to me. I will do a little experimentation with some innocuous stuff that isn't important. Thanks for being helpful. Bob S -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
----- Original Message -----
From: "Bob S" <911@sanctum.com>
To:
On Tuesday 08 July 2008 06:35:10 am Brian K. White wrote:
----- Original Message ----- From: "Bob S" <911@sanctum.com> To:
Sent: Monday, July 07, 2008 8:13 PM Subject: [opensuse] Two simple rsync questions 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.
<snip instructions>
Wow Brian you sound like the man page, but lots more instructive. I read the man page several times and found it confusing for somebody who has never used the program. info man did give some examples.
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.
I am simply preserving files and their structure to a USB hard drive. Some of those instructions sound a little scary to me. I will do a little experimentation with some innocuous stuff that isn't important. Thanks for being helpful.
Just for the record, even though I use rsync _all_ the time, all day every day numerous times on lots of boxes, aross several platforms etc... Even so, I routinely have to pore over the man-page to see if a particular option exists, or what it's exact behavior is supposed to be, and then I still have to do several trial&error test runs until I get the effect I want. Just today I finally got around to improving my main backup scripts to replicate leading paths automatically on the destination. Took many many false starts to get it to, for example, create a missing /etc directory on the far end and place passwd in it, without also copying all rest of /etc. I finally discovered that at least on very recent versions there is a -R option that does exactly what I want, and I don't have to try to do it the hard way using a specially arranged inclusion/exclusion list and --filter So I can have backup / server-mirror config files that have a nice simple list of file & directory names in them that even my co-workers have a reasonable chance of editing without breaking. And the directory structure will be replicated on the fly within a new empty backup directory on the backup server, greatly simplifying initial setup of each new server that wants to back up to the backup server. Granted much of this was working on enhancing other features of the script not just the rsync commands themselves, but it took me the last several hours to get it working just right and be robust and safe. And as I said, I use rsync all the time as casually as cp or ls, and I was only enhancing a script that was already written and tested and in heavy use on a lot of boxes, not even writing a new thing from scratch. So don't feel bad that it seems like a lot of reading and too much info to handle at once. It IS! But, thats the built-in and unavoidable price of great power. :) -- 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
On Mittwoch, 9. Juli 2008, Brian K. White wrote:
Just for the record, even though I use rsync _all_ the time, all day every day numerous times on lots of boxes, aross several platforms etc... Even so, I routinely have to pore over the man-page to see if a particular option exists, or what it's exact behavior is supposed to be,
Welcome to the club. ;-)
and then I still have to do several trial&error test runs until I get the effect I want.
Right. As a general rule of thumb, always try with the "-n" (or --dry-run)
option first, and only if that looks good, take away the "-n".
I can never remember if I need
rsync -av /some/where/mydir .
or
rsync -av /some/where/mydir/ .
which _is_ a huge difference (one of them creates ./mydir and copies the files
below that point, the other copies them to the current directory right away).
It's a powerful beast, and like all powerful beasts, it's not easy to be
tamed. ;-)
CU
--
Stefan Hundhammer
participants (7)
-
Bob S
-
Brian K. White
-
Carlos E. R.
-
Dave Howorth
-
Sampsa Riikonen
-
Stefan Hundhammer
-
Sudhir