On Tue, Dec 16, 2008 at 7:13 PM, R.G.Salisbury <[email protected]> wrote: > > ----- Original Message ----- From: "James Polley" <[email protected]> > To: "R.G.Salisbury" <[email protected]> > Cc: <[email protected]> > Sent: Tuesday, December 16, 2008 4:35 PM > Subject: Re: [SLUG] Just sharing a gotcha with "rsync" that caused me big > trouble ...extra > > >> There is nothing more worthy of contempt than a man who quotes himself >> - Zhasper, 2004
What was that idiot thinking, putting his sig at the top of the.. wait, that was me. never mind. >> >> >> >> On Sun, Dec 14, 2008 at 11:38 PM, R.G.Salisbury >> <[email protected]> wrote: >>> >>> Just sharing a gotcha with "rsync" that caused me big trouble ... >>> >>> what's nasty about rsync ? .. >>> .. which may cause devastating consequences. >>> >>> rsync is in my opion the best thing since sliced bread... but be careful. >>> >>> >>> >>> CLI commands -- cp, rcp, scp, rsync, all have similarites >>> BUT there are some nasty gotcha's when switching from one to another. >>> >>> You probably noticed some oddities , but had worked around it. (with the >>> help of an error message) >>> Without an error message you may had come to grief. >>> >>> Consider .............. >>> >>> Scenario: >>> For whatever reason -- you want to restore the /etc directory from a >>> local backup. >>> Lets just use a simple example.. >>> >>> "cp" should handle this. >>> "rsync" should also should handle this. >>> >>> But "cp" is your friend if you make an error ... "rsync" is not. >>> >>> OK .... There is NO source or destinantion directory "ets" but you >>> make a >>> typo "ets" instead of "etc" >>> >>> "cp" will give you an error message whereas "rsync" will do what is >>> not >>> intended and you will be *unaware* >>> >>> So the following commands >>> >>> [r...@localhost ~]# cp -a /backup/etc/* /ets >>> >>> [r...@localhost ~]# rsync -a /backup/etc/* /ets >>> >>> >>> "cp" will error out telling you that the target is not a directory >> >> if you use cp -ar /backup/etc /etc, cp, won't give you a warning. > > Thanks for reinforcing my point James > cp -ar /backup/etc /etc > > will produce /etc/etc > & the data is in the wrong place ---- DISASTER again! Disaster? Not really - I've just got a spare copy around now, which I can easily remove with a quick rm -rf /etc/etc* - but wait, that really could be a disaster. It sounds like we're agreed: double-check your commandline; do a dry-run if you can, get verbose output *and* pay attention to it, and then make sure you check the results afterwards. Oh, and always have a backup, because sooner or later you're going to screw up anyway. > >> >>> whereas >>> "rsync will SILENTLY create the dir (ets) and populate it. >> >> so add a "-v" and you'll see some output telling you "created directory >> ets". >> >> This is not unusual. Most unix commands only bother you when there's a >> problem, and there was no problem here. >> >> Of course, you're going to ignore that output anyway, aren't you... >>> >>> So if you didn't check the result .... disaster beckons. >> >> So check it. >>> >>> Note that the creation of directories occur without a trailing slash on >>> the source. >>> But in that instance directory created is the name of the source >>> directory. >> >> Note that blindly using *any* command, without paying attention, >> without understanding what you're doing, can lead to disaster. This is >> a PEBKAC, not a fault of the tool. >> >>> >>> >>> I have found some other gotchas ...... But do be aware of this (nasty) >>> feature. >>> Won't go into detail .... but some are ......... >> >> No, please do! >> >>> Like the deal with the trailing slash ..... which can cause issues --- >>> (often put there by bashs tab completion). >>> I like putting a "*" after a trailing slash as i find it more intuitive. >>> Also ........ creating a new dir once -- but not twice.. >>> Blah..Blah >>> >>> Cheers >>> Roger >>> -- >>> SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/ >>> Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html >>> > > -- SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/ Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html
