Failed to copy new file using scp

  • Follow


I am using command to backup a remote folder at (192.168.11.23) to
local server

e.g.
    scp -r user@192.168.11.23:/home/backup /home/backup

It WORKED when  /home/backup does not exist in local folder.

After the first scp, I add new files under 192.168.11.23:/home/backup/
new.txt

Then I run The scp again, but this time it failed to copy the new
file.

So I remove the /home/backup in local folder and re-run the scp, and
it work.

Any idea?

Thanks.
0
Reply howachen (515) 2/19/2009 11:02:03 AM

howa wrote:

> I am using command to backup a remote folder at (192.168.11.23) to
> local server
> 
> e.g.
>     scp -r user@192.168.11.23:/home/backup /home/backup
> 
> It WORKED when  /home/backup does not exist in local folder.
> 
> After the first scp, I add new files under 192.168.11.23:/home/backup/
> new.txt
> 
> Then I run The scp again, but this time it failed to copy the new
> file.
> 
> So I remove the /home/backup in local folder and re-run the scp, and
> it work.
> 
> Any idea?
> 
> Thanks.

Look at a trailing forward slash on the example above.  Also, consider
using rsync over SSH, as this is usually better for these type of
situations.
-- 
Tim Greer, CEO/Founder/CTO, BurlyHost.com, Inc.
Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers
and Custom Hosting.  24/7 support, 30 day guarantee, secure servers.
Industry's most experienced staff! -- Web Hosting With Muscle!
0
Reply tim199 (261) 2/19/2009 5:24:08 PM


On Feb 20, 1:24=A0am, Tim Greer <t...@burlyhost.com> wrote:
> howa wrote:
>
> Look at a trailing forward slash on the example above. =A0Also, consider
> using rsync over SSH, as this is usually better for these type of
> situations.

tried all...

scp -r user@192.168.11.23:/home/backup/ /home/backup/
scp -r user@192.168.11.23:/home/backup /home/backup


still no luck...only way is to remove whole folder in local and re-run
the scp again to copy from remote ...and it is ok...

I don't copy the file frequently, so scp is preferred...maybe this is
a bug?


0
Reply howachen (515) 2/20/2009 10:21:59 AM

>> Look at a trailing forward slash on the example above.  Also, consider
>> using rsync over SSH, as this is usually better for these type of
>> situations.

howa <howachen@gmail.com> wrote:
> tried all...
> scp -r user@192.168.11.23:/home/backup/ /home/backup/
> scp -r user@192.168.11.23:/home/backup /home/backup

Your commands will variously either have been creating a subdirectory
called backup inside the target /home/backup directory, or putting the
files from /home/backup directly into the target's /home, so although the
copy worked, none of them has done what you thought it should have done.

Try this instead:

    scp -r user@192.168.11.23:/home/backup /home/


> I don't copy the file frequently, so scp is preferred...maybe this is
> a bug?

Like the OP I'd still recommend rsync, though:

    rsync -avP user@192.168.11.23:/home/backup /home/

That isn't too painful..?
Chris
0
Reply chris-usenet (1112) 2/20/2009 6:10:11 PM

Hey,

On Feb 21, 2:10=A0am, Chris Davies <chris-use...@roaima.co.uk> wrote:
> so although the
> copy worked, none of them has done what you thought it should have done.
>

I have tried your suggestion and it work....but can you explain why my
command not working? (I want to know the reason)

Thanks.
0
Reply howachen (515) 2/26/2009 5:09:46 PM

howa wrote:

> Hey,
> 
> On Feb 21, 2:10 am, Chris Davies <chris-use...@roaima.co.uk> wrote:
>> so although the
>> copy worked, none of them has done what you thought it should have
>> done.
>>
> 
> I have tried your suggestion and it work....but can you explain why my
> command not working? (I want to know the reason)
> 
> Thanks.

I'm confused, what worked and what didn't work?  Above you said it
worked, but wanted to know why it didn't work?  Do you mean it worked
when you removed the trailing forward slash/ on the source directory? 
Or do you mean that you've used rsync instead and it worked and you
want to know why scp didn't?  Please elaborate.
-- 
Tim Greer, CEO/Founder/CTO, BurlyHost.com, Inc.
Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers
and Custom Hosting.  24/7 support, 30 day guarantee, secure servers.
Industry's most experienced staff! -- Web Hosting With Muscle!
0
Reply tim199 (261) 2/26/2009 5:42:56 PM

On Feb 21, 2:10 am, Chris Davies <chris-use...@roaima.co.uk> wrote:
> [...] so although the copy worked, none of them has done what you
> thought it should have done.

howa <howachen@gmail.com> then asked:
> I have tried your suggestion and it work....but can you explain why my
> command not working? (I want to know the reason)


I gave the reason along with my suggestions, which you have carefully
chopped out of the context you've quoted above. Let me repeat it in its
entirety, here:

| Your commands will variously either have been creating a subdirectory
| called backup inside the target /home/backup directory, or putting the
| files from /home/backup directly into the target's /home, so although
| the copy worked, none of them has done what you thought it should
| have done.


Which bit do you need explaining in more detail?
Chris
0
Reply chris-usenet (1112) 2/26/2009 11:22:01 PM

Hey,

On Feb 27, 7:22=A0am, Chris Davies <chris-use...@roaima.co.uk> wrote:
> | Your commands will variously either have been creating a subdirectory
> | called backup inside the target /home/backup directory, or putting the
> | files from /home/backup directly into the target's /home, so although
> | the copy worked, none of them has done what you thought it should
> | have done.
>
> Which bit do you need explaining in more detail?
> Chris


My confusion is it DID work if my local folder does not exist. But it
is not working if my local folder exist.

So I think if my command is not correct at all, then no matter my
local folder exist or not .... it should not copy anyway?

Isn't?
0
Reply howachen (515) 2/28/2009 4:57:48 AM

howa wrote:

> Hey,
> 
> On Feb 27, 7:22 am, Chris Davies <chris-use...@roaima.co.uk> wrote:
>> | Your commands will variously either have been creating a
>> | subdirectory called backup inside the target /home/backup
>> | directory, or putting the files from /home/backup directly into the
>> | target's /home, so although the copy worked, none of them has done
>> | what you thought it should have done.
>>
>> Which bit do you need explaining in more detail?
>> Chris
> 
> 
> My confusion is it DID work if my local folder does not exist. But it
> is not working if my local folder exist.
> 
> So I think if my command is not correct at all, then no matter my
> local folder exist or not .... it should not copy anyway?
> 
> Isn't?

What? ? ? ? Try it with the directory existing and one without it
existing.  Then try both the trailing forward slash/ and without and
you'll immediately see the difference.  Make a note.  It doesn't change
its behavior, and then you'll know exactly, since it seems a little
hard to explain in a way that's clear.  That's okay, not everyone
receives and memorizes information the same way and usually remember by
doing.  Do it a few times and note the specific differences.  Then
maybe come back and re-read what he said and if it doesn't make sense,
don't worry (because now you know what the differences will be anyway).
-- 
Tim Greer, CEO/Founder/CTO, BurlyHost.com, Inc.
Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers
and Custom Hosting.  24/7 support, 30 day guarantee, secure servers.
Industry's most experienced staff! -- Web Hosting With Muscle!
0
Reply tim199 (261) 2/28/2009 6:43:19 AM

howa <howachen@gmail.com> writes:

>Hey,

>On Feb 27, 7:22=A0am, Chris Davies <chris-use...@roaima.co.uk> wrote:
>> | Your commands will variously either have been creating a subdirectory
>> | called backup inside the target /home/backup directory, or putting the
>> | files from /home/backup directly into the target's /home, so although
>> | the copy worked, none of them has done what you thought it should
>> | have done.
>>
>> Which bit do you need explaining in more detail?
>> Chris


>My confusion is it DID work if my local folder does not exist. But it
>is not working if my local folder exist.

>So I think if my command is not correct at all, then no matter my
>local folder exist or not .... it should not copy anyway?

He argues that your command DID work in all cases.  The problem was that if
the file exists, it did not copy the contents of the source to the contents
of the destination, but the source directory INTO the target directory. 

Eg, lets say that source was bugsbunny, and the target was /tmp/bugsbunny,
when you did 
scp -pr bugsbunny /tmp/bugsbunny 
what you got was was
/tmp/bugsbunny/bugsbunny 
containing the contents.  That was probably not what you wanted. 


>Isn't?
0
Reply unruh-spam (2581) 2/28/2009 7:07:54 AM

howa <howachen@gmail.com> wrote:
> My confusion is it DID work if my local folder does not exist. But it
> is not working if my local folder exist.

You'll find that commands like "mv" work in exactly the same way.

    mkdir a a/b c	# Create some directories
    touch a/b/f		# ...containing content
    mv a/b c/x		# Move "b" into "c" renaming it as "x"

    find * -print | sort

This leaves you with empty "a" but now "c/x" (containing "f"). You have
not only moved "b" from "a" into "c" but also renamed it from "b" to
"x" all in one operation.

Now repeat the process...

    mkdir a/b		# Create "a/b" again
    touch a/b/g		# ...containing more content
    mv a/b c/x		# Move "b" into "c/x"

    find * -print | sort

Here, you have moved "b" into the "c/x" directory. There has been no
rename operation since "c/x" already existed so there was no component
left to function as a rename.


> So I think if my command is not correct at all, then no matter my
> local folder exist or not .... it should not copy anyway?

I guess that depends on your interpretation.

Ultimately, though, if you want the command to do what you want, you
have to play by its rules and remember the trailing slash.

Chris
0
Reply chris-usenet (1112) 2/28/2009 8:26:09 PM

10 Replies
93 Views

(page loaded in 0.142 seconds)

Similiar Articles:













7/25/2012 11:24:14 PM


Reply: