Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I just completed a magento website online, but I don't have any of the files on my local hard drive (couldn't install it on MAMP). But I would like to make a back up.

My hosting company lets me connect to the server through SSH on my mac terminal.

My question is, what is the line of command to copy from server to local drive?

With a sample path and/or example would be nice...and I'm also guessing it is a good idea to tar it before hand, how do I do that?

Thanks for the help.

share|improve this question

migrated from stackoverflow.com Aug 11 '11 at 20:31

This question came from our site for professional and enthusiast programmers.

add comment

4 Answers

If you're running Linux locally, you can use scp (secure copy) to transfer files from:

  • remote to local

  • local to remote

  • remote to remote

Syntax for remote to local:

scp username@server:/remote/path/to/file /path/to/local/dir

If you're transferring many files, it's probably a good idea to tar the files. Here's a reference on the tar syntax and options you may want:

http://www.computerhope.com/unix/utar.htm

share|improve this answer
add comment

You should use rsync over ssh to make the backup:

$ rsync -avz -e ssh remotehost:/path/to/site /local/backup/directory/

It's restartable and only transfers what you need.

share|improve this answer
add comment

If you want to save a tar file on your mac, here is another option.

ssh user@server '( cd /remote/path/ && tar cfz - . )' > site_backup.tar.gz

This option uses no extra disk space on the remote machine. It creates the tar file and immediately pushes it out over the ssh connection and saves it on your Mac.

share|improve this answer
    
I get this error in the terminal, do you know what it means? or what I need to do? "tar: Old option `f' requires an argument" –  denislexic Aug 12 '11 at 7:00
    
hmm, try this: ssh user@server '( cd /remote/path && tar cf - . | gzip -9 )' > site_backup.tar.gz –  toppledwagon Aug 12 '11 at 7:17
    
f should be last: tar czf –  Eelvex Aug 12 '11 at 9:11
add comment

You can use WinSCP as a windows client if you need to transfer files from a remote server to a local windows machine via SSH.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.