"rsync" from remote to local

15,836

Try this:

rsync -ave 'ssh -p 456' /home/cavo/python/ [email protected]:/home/wolfy/py/ 

Note that the trailing slashes on the paths are very important, they signal that you are syncing a directory to a directory. The -e switch helps rsync know it is going to be using ssh transport, and while we are specifying the transport we also tell ssh what port it's going to have to use to talk to the remote site. Then the username and remote host ip are specified as part of the target.

Share:
15,836

Related videos on Youtube

Wolfy
Author by

Wolfy

Updated on September 18, 2022

Comments

  • Wolfy
    Wolfy over 1 year

    Let say that I have 2 machines:

    • local (centos)
    • remote on IP: 123.123.123.123 ssh port 456 (ubuntu server)

    and I want to synchronize my remote folder /home/wolfy/py with my local folder /home/cavo/python.

    Can this be done with rsync? Can you give me an example?

  • Wolfy
    Wolfy almost 13 years
    works perfectly :) thanks for a detailed explain!
  • enzotib
    enzotib almost 13 years
    Trailing slash is only important on the source, not on destination.
  • Daniel F
    Daniel F about 7 years
    I'm confused, doesn't this copy from local to remote? According to stackoverflow.com/a/9090859/277267 it's the other way around.
  • Caleb
    Caleb about 7 years
    @DanielF Yes it does. I suspect that's what the OP meant by his question. Note his use of "with" and the unconventional wording. If you really want to sync a remote dir to a local one you can reverse the arguments. Source first then target.
  • Daniel F
    Daniel F about 7 years
    @Caleb Yes, but title says "from remote to local".
  • Caleb
    Caleb about 7 years
    @DanielF note the OP commented above to say this worked as expected. The issue was how to tell rsync about the ssh parameters not which direction to sync. The question us unclearly worded but it doesn't matter which is local vs remote, source path comes first and target second. They can even both be remote.