Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 Aug 11 '11 at 20:31

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

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:

share|improve this answer

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

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

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

Your Answer


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.