Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

SSH Copy Local File to Remote Server

Posted on 2011-09-27
14
Medium Priority
?
415 Views
Last Modified: 2012-08-13
I have 3 .sql database dumps that I need to import via command line because they are each over 3G in size.  I am not that advanced in command line management, so I'm not sure if I'm doing this right.

I have the .sql file located in a local folder, ex: C:\databack\inboxcor_311_leads_dump.sql , but I keep getting a "No such file or directory" error when trying to run the scp copy command.  I'm sure I'm not putting the path right, so if somebody could help me.....?

When logged in to PuTTY as root:

scp /databack/inboxcor_311_leads_dump.sql root@50.30.33.46:/var/www/vhosts/inboxmediacorp.com/httpdocs/databack



scp /databack/
0
Comment
Question by:kageboy2003
  • 9
  • 4
14 Comments
 
LVL 21

Expert Comment

by:Papertrip
ID: 36713623
I'm confused.  So you are on a Windows machine, your .sql files are on that same machine, and your target box is some Unix server correct?

Use WinSCP to get the files over.

There is also PSCP from the same people as PuTTY, but I prefer WinSCP.
0
 
LVL 21

Expert Comment

by:Papertrip
ID: 36713637
If you were logged into your Unix/Linux box, and typed the following:
scp /databack/inboxcor_311_leads_dump.sql root@50.30.33.46:/var/www/vhosts/inboxmediacorp.com/httpdocs/databack

Open in new window


It would try to copy /databack/inboxcor_311_leads_dump.sql on the Unix machine to root@50.30.33.46:/var/www/vhosts/inboxmediacorp.com/httpdocs/databack, which I'm guessing is the IP of the same Unix machine, correct?

In that case the error you received was because the file /databack/inboxcor_311_leads_dump.sql does not exist on your Unix machine, and if it did, and that IP is in fact the same machine, then you would have copied /databack/inboxcor_311_leads_dump.sql to /var/www/vhosts/inboxmediacorp.com/httpdocs/databack.
0
 

Author Comment

by:kageboy2003
ID: 36713649
The local machine is my Windows computer at work.  I am trying to get the files uploaded to our remote server (UNIX) and I was under the impression that using SCP is faster than FTP.  

I do have WinSCP as you suggested, and I noticed that when I login as root, I don't see the folders I need to upload too.  Maybe I need to login as a FTP user rather than root?
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 

Author Comment

by:kageboy2003
ID: 36713651
Sorry...in regards to your question...no they are two different IP's and machines.
0
 
LVL 21

Expert Comment

by:Papertrip
ID: 36713663
When you login via WinSCP, you are going to be placed in the users home directory just like if you were to SSH in.  you will need to navigate through the filesystem to get to your destination -- ".." means parent directory, but you can probably type in an absolute path as well.

If you were to login via FTP, it would require an FTP server be listening on the Unix side, and even then you would be locked into only the directories that the FTP server was setup to use.
0
 
LVL 21

Accepted Solution

by:
Papertrip earned 2000 total points
ID: 36713677
Ah misread your last statement, you said ftp user as opposed to ftp server.

If you can login as root, then you are fine, no need to login as any other user (although it might create a permissions issue in your Apache directory when you copy it, unless setgid is turned on for the directory.
0
 
LVL 21

Expert Comment

by:Papertrip
ID: 36713680
Login as the user that you would normally use to copy files for your web server.
0
 

Author Comment

by:kageboy2003
ID: 36713708
OK.  I'm going to go ahead and use WinSCP, but can you tell me why I wasn't able to do it from the command line in PuTTY?  I'm trying to learn my way around the command line and wanted to know for future experience.  Did I have the path wrong?  I even tried with the \ in the path for Windows and I still got the error.  What would have been the proper path to a local computer file?

Thanks.
0
 
LVL 21

Expert Comment

by:Papertrip
ID: 36713727
I tried to explain it in http:#36713637 but I know it wasn't very clear, so here is a better version.

What would have been the proper path to a local computer file?
That's just it -- you were on the Unix box while using scp, that makes C:\databack\inboxcor_311_leads_dump.sql a remote file.
0
 

Author Comment

by:kageboy2003
ID: 36713748
I still am a bit confused.  So you're saying that I would have had to login to my local computer in order to do the copy?  All the examples I read did not mention anything about that.  

Also, is SCP transfer actually faster than FTP?  That was the only reason I wanted to try from the command line because I understand it is a faster process.
0
 
LVL 21

Expert Comment

by:Papertrip
ID: 36713830
scp /databack/inboxcor_311_leads_dump.sql root@50.30.33.46:/var/www/vhosts/inboxmediacorp.com/httpdocs/databack

That says take the file /databack/inboxcor_311_leads_dump.sql on the Unix box and copy it to /var/www/vhosts/inboxmediacorp.com/httpdocs/databack on the Unix box.  The actual source file from the is still on the Windows machine, you haven't copied to the Unix box yet.

You are running scp on the Unix machine right? 50.30.33.46 is that same Unix machine right?
0
 
LVL 21

Expert Comment

by:Papertrip
ID: 36713861
Using SCP with compression turned on for a file like an SQL dump will most likely be much faster than normal FTP.
0
 
LVL 48

Expert Comment

by:Tintin
ID: 36713876
Compression is only really useful for slow links.  In general, scp is slower than FTP because of the encryption overhead.
0
 
LVL 21

Expert Comment

by:Papertrip
ID: 36713939
@Tintin
Yeah definitely most useful for slow links, but what about something like a large text file over a normal link?  I admit I have never tried it since I would just gzip the file first, can't test it right this moment.

Speaking of that, kageboy you should just compress that file first then use either scp, or FTP if you prefer.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
Recently, an awarded photographer, Selina De Maeyer (http://www.selinademaeyer.com/), completed a photo shoot of a beautiful event (http://www.sintjacobantwerpen.be/verslag-en-fotoreportage-van-de-sacramentsprocessie-door-antwerpen#thumbnails) in An…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question