On Sun, 05 May 2013 06:35:40 -0400 Anton Aylward wrote:
Carl Hartung said the following on 05/05/2013 12:31 AM:
On Sun, 5 May 2013 03:21:02 +0200 (CEST) Carlos E. R. wrote:
On Friday, 2013-05-03 at 10:30 -0400, Carl Hartung wrote:
One other item: I use the flags '-avAX' followed by '--delete' without the '--delete-after'. More below.
I once destroyed a system when attempting to do backup. I was using - --delete and I wrote the wrong source and target directories - as both did not match, the destination was deleted.
Ouch!
You're supposed to "engage your brain" [as in 'engaging' gears in a transmission] *before* tapping the 'Enter' key!
;-)
This is precisely why I always, always, always _stop_ beforehand to read back and contemplate, to confirm, my typing _before_ committing to the operation.
Indeed, but it helps if the documentation/man page is clear about such matters. personally I think the section on "delete" is so badly written that I don't understand it however much I stop and contemplate.
My "commit" is simply not to use it.
Perhaps I am crippling myself by not using the capabilities of rsync, but then again, I avoid a misunderstanding and hence avoid wiping my system.
I highly doubt you're "crippling" yourself, Anton. Obviously, other tools can be used. I'll say this, though: Once you've familiarized yourself with rsync enough to use it every day, it becomes an indispensable part of your toolkit. The biggest problem I had was figuring out that the last slash ('/') in the *source* path acts like a "container." From rsync's perspective, it determines at the outset what is (and is not) written to the target: /source/xyz Here, the last slash "contains" the directory "xyz". Used in this form, rsync will copy the directory "xyz" and it's contents to the target. /source/xyz/ Here, the last slash does _not_ "contain" the directory "xyz". Used in this form, only the contents of "xyz" are copied to the target. /target/xyz rsync treats both of these target paths equally, i.e. /target/xyz/ the trailing slash is implied when omitted. This is comparable to the behavior of 'cp', 'rm', 'rmdir', 'mv', etc. Also, I really only use the following options on a regular basis: -a, --archive archive mode Replicates the source directory, recursively, preserving owners, timestamps and permissions (sort of like 'tar' but the target is another directory instead of a file.) Add 'A' and 'X' flags to preserve, respectively, ACLs and extended attributes. Caveat: It operates exactly as stated above when invoked as root. When invoked by a regular user, it writes to the target as that user (local system.) -r, --recursive recurse into directories Recurse and preserve permissions, but not owners or timestamps (i.e. write as current user with current timestamps.) -v, --verbose increase verbosity -A, --acls preserve ACLs -X, --xattrs preserve extended attributes -n, --dry-run perform a trial run with no changes made I often use this option with redirection or piping to casually examine the results of a contemplated rsync operation. It causes rsync to undertake the operation without actually writing any changes to disk. piping example: rsync -rvn --delete /source/ /target | less redirection example: rsync -rvn --delete /source/ /target >somefilename.txt --delete delete extraneous files from destination --delete-during receiver deletes during the transfer --del an alias for --delete-during Notes regarding the above 'flavors' of '--delete': '--delete' deletes items from the target that are not (i.e. "no longer") present at the source. In my experience, this is functionally equivalent to '--delete-during', where writing of new and changed items and deletions occur sequentially, in the order they are evaluated. Omitting '--delete' actually precludes true synchronization since this leaves items untouched at the target when they're not (i.e. are "no longer") present at the source. This is akin to an incremental backup, where items are added and updated, never deleted. Some notes regarding the other 'flavors' of '--delete' which I actually don't ever use: --delete-before deletions occur before new and changed files are written --delete-delay deletions occur after new and changed files are written --delete-after deletions occur after new and changed files are written --delete-excluded delete exclusions from the destination This last one could be used to remove items from a target that were previously, inadvertently, copied for lack of an earlier '--exclude' directive. From what I've read, the other three are meant to satisfy more 'fringe' or obscure scenarios where remote targets have other than native *nix filesystem types, older rsync versions or rsync implementations running on other operating systems. I could be wrong, but that's my take on them ATM. regards, Carl -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org