Re: [SLUG] Just sharing a gotcha with "rsync" that caused me big trouble ...extra

2008-12-16 Thread Matthew Hannigan
On Tue, Dec 16, 2008 at 07:34:10PM +1100, Patrick Lesslie wrote:
> On Sun, Dec 14, 2008 at 11:38:10PM +1100, R.G.Salisbury wrote:
> > 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.
> 
> The trailing slash or not option is handy once you know about it, but
> confusing until you do.
> 
> It also makes a difference whether you put a "*" after the trailing slash
> or not, since the shell interpolates the "*" and doesn't include hidden
> files, which may be important for a home directory backup for example.

Here's an idiom which has saved me thinking too hard; use . as the source:

cd /whatever/source/ && rsync -a . /some/destination/directory

It will work the same whether source is just source or source/
It will fail nicely if /some/destination/directory doesn't exist
It will work the same with the same sort of errors if you use cp -a
instead of rsync -a.
It picks up .files in source as well which rsync source/* /some/dest/ doesn't.


Matt

-- 
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html


Re: [SLUG] Just sharing a gotcha with "rsync" that caused me big trouble ...extra

2008-12-16 Thread James Polley
On Tue, Dec 16, 2008 at 7:13 PM, R.G.Salisbury
 wrote:
>
> - Original Message - From: "James Polley" 
> To: "R.G.Salisbury" 
> Cc: 
> 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
>>  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


Re: [SLUG] Just sharing a gotcha with "rsync" that caused me big trouble ...extra

2008-12-16 Thread Patrick Lesslie
On Sun, Dec 14, 2008 at 11:38:10PM +1100, R.G.Salisbury wrote:
> 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.

The trailing slash or not option is handy once you know about it, but
confusing until you do.

It also makes a difference whether you put a "*" after the trailing slash
or not, since the shell interpolates the "*" and doesn't include hidden
files, which may be important for a home directory backup for example.

Patrick Lesslie
-- 
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html


Re: [SLUG] Just sharing a gotcha with "rsync" that caused me big trouble ...extra

2008-12-16 Thread R.G.Salisbury


- Original Message - 
From: "James Polley" 

To: "R.G.Salisbury" 
Cc: 
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



On Sun, Dec 14, 2008 at 11:38 PM, R.G.Salisbury
 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!




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


Re: [SLUG] Just sharing a gotcha with "rsync" that caused me big trouble ...extra

2008-12-15 Thread Henare Degan
On Tue, Dec 16, 2008 at 16:35, James Polley  wrote:
> 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.

Furthermore, rsync has airbags:

-n, --dry-run   perform a trial run with no changes made

Cheers,

h
-- 
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html


Re: [SLUG] Just sharing a gotcha with "rsync" that caused me big trouble ...extra

2008-12-15 Thread James Polley
There is nothing more worthy of contempt than a man who quotes himself
- Zhasper, 2004



On Sun, Dec 14, 2008 at 11:38 PM, R.G.Salisbury
 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.

> 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


[SLUG] Just sharing a gotcha with "rsync" that caused me big trouble ...extra

2008-12-15 Thread R.G.Salisbury
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
whereas
"rsync  will SILENTLY create the dir (ets) and populate it.

So if you didn't check the result  disaster beckons.

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.


I have found some other gotchas .. But do be aware of this (nasty)
feature.
Won't go into detail  but some are .
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