0

I've had a look on google and here on stack but can't find a good example on how to do this.

All I basically want to do is SSH into a server copy all the site files and paste them into a folder on my computer?

I normally use git but this is an old site which has not been setup with git so I just wanted to know a quick way to copy from the server as FTP sucks!

A simple process with commands for terminal would be great!

mylesthe.dev
  • 9,267
  • 4
  • 20
  • 34
  • possible duplicate of [How to download a file from server using SSH?](http://stackoverflow.com/questions/9427553/how-to-download-a-file-from-server-using-ssh) – vladkras Feb 03 '14 at 03:55
  • FTP stands for **File Transfer Protocol**, so it's no reason to say that it sucks for file transferring. Btw, [SCP](http://en.wikipedia.org/wiki/Secure_copy) is only another protocol, not supertool that can do magic and also requieres only one line to copy files: `scp ...` (for scp) and `mget ...` for ftp – vladkras Feb 03 '14 at 04:09
  • @vladkras i meant GUI FTP always seem to be a lot slower than doing it via command line. Thanks for the link to SCP :) – mylesthe.dev Feb 03 '14 at 04:24
  • you're welcome, and yep, the difference is in only in secured transfer, but do you REALLY need it for your images and css files? It's a little bit faster only if you're already logged in via ssh – vladkras Feb 03 '14 at 06:29

4 Answers4

3

Check out rsync. It has the capability to operate over ssh. You might also want to look into ssh aliases (which it also honors) when copying files over, and it's what git uses to only sync the differences between two repositories.

The advantage of rsync over SCP or SFTP is that it can resume download if interrupted, takes little bandwidth to sync since it sends change sets instead of entire files (unless the file doesn't yet exist on one side), and can do one- or two-way sync depending on your preference.

TheLonelyGhost
  • 317
  • 6
  • 11
  • I've seen a solution to mount an FTP site using on a user folder using `curlftpfs` . If that succeeds than `sync` should run locally as well. In case anybody is stuck on FTP. – Maarten Bodewes Oct 29 '14 at 00:35
1
ssh USER@SERVER "tar zcvf - /DUMP_DIR" | cat > /OUT_DIR/FILE_NAME_OF_ARCH

or

(rsync -avz --delete /DUMP_DIR USER@SERVER:/OUT_DIR &)
shilovk
  • 7,603
  • 15
  • 54
  • 63
0

Use scp

scp -P 2222 json-serde-1.1.8-SNAPSHOT-jar-with-dependencies.jar root@127.0.0.1:

For Example.

Hope that helps!

Thinkhear
  • 292
  • 2
  • 4
0

Look at SCP.

scp username@remotehost.com:/directoryname/* /some/local/directory

Akhilesh Singh
  • 2,330
  • 1
  • 11
  • 10
  • I tried - scp username@ip:/httpdocs/* /sitecopy/ But i got scp: /httpdocs/*: No such file or directory ? – mylesthe.dev Feb 03 '14 at 04:19
  • 1
    /httpdocs will mean it is under the root of filesystem. I believe you will need to give your home directorty followed by httpdocs. To get the absolute directory location, you can use "pwd" in the httpdocs folder and use it in place of directoryname. – Akhilesh Singh Feb 03 '14 at 09:20
  • Thanks @AkhileshSingh, I now get permission denied. Do i need to run this as root? I was previously using the account details not the root. – mylesthe.dev Feb 03 '14 at 19:31
  • You need have to use the root but the username of the server. Most probably you are using the username of the local system and not the server. – Akhilesh Singh Feb 04 '14 at 13:34