Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 have a Ubuntu server hosted on Amazon EC2. I need to create an automated backup scheme so I created another Ubuntu instance on my local network which is hosted in a virtual environment.

I managed to transfer the necessary files between 2 machines on the same network using the rsync command:

rsync -azvv -e ssh /home/path/folder1/ remoteuser@remotehost.remotedomain:/home/path/folder2

How can I do the same thing but transferring files from my Amazon server to my local server? Is there a way I can achieve this with port forwarding, or by VPN, or anything else?

It doesn't have to be rsync. If you know about a better method, kindly let me know.

share|improve this question
up vote 1 down vote accepted

Just swap both locations:


so in your case the following should do the job:

rsync -azvv -e ssh remoteuser@remotehost.remotedomain:/home/path/folder2 /home/path/folder1/
share|improve this answer
So are you saying that I should connect from my local machine terminal to my remote machine? Makes sense. The thing is that my local machine uses password authentication while the remote uses public key. Therefore when I connect from my local machine, it asks for the password of the remote machine, which it does not has. How can I bypass this? – seedg Jun 28 '11 at 11:48
According to your command rsync [...] remoteuser@remotehost.remotedomain:[...] you should be able to connect to remotehost via ssh!? My command just connects with the same account at the same host, so why should it fail? Please run both commands from the same machine. Sine you are not explicitely connecting to your local machine you don't need the password for the local host. – binfalse Jun 28 '11 at 11:56
What I did was I added my public key code of the amazon server to the authorized_hosts of the local server and there is no need for a password – seedg Jun 30 '11 at 7:11

So you want to setup an automated backup between your local server and an amazon hosted server?

  1. Configure the ssh keys between your local server and your amazon server.

    foo@local-server $ ssh-keygen
    foo@local-server $ scp ~/.ssh/ amazon-server:~/
    foo@amazon-server $ cat ~/ >> .ssh/authorized_keys

    You should be able to ssh from the local server to the remote server without needing a password. Make sure the permissions on the .ssh directory and authorized_keys file are 700 and 600 respectively.

  2. Run your rsync command from your local server

    foo@local-server $ rsync -azvv amazon-server:folder2 ~/folder1/
  3. You'll probably want to set this up as a cronjob running from your local server

    foo@local-server $ crontab -e

    Add something like the following to your crontab. This will run the backup at midnight every night.

    * 0 * * *  rsync -azvv amazon-server:folder2 ~/folder1/
share|improve this answer
have a look at ssh-copy-id to make the copy of ssh keys. – Johan Jun 28 '11 at 20:30
That's exactly what I did. – seedg Jun 30 '11 at 7:11

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.