How to specify a path relative to user home directory for destination when using rsync over ssh

rsync

I am using rsync over ssh and trying without success to sync files to a place inside user home directory.

All the time rsync seams to want to use full paths.

Tried things like:

  • rsync --rsh=ssh /src/ user@server:/dst – obviously creates it in root if it can
  • rsync --rsh=ssh /src/ user@server:~/dst
  • rsync --rsh=ssh /src/ user@server:~dst – creades ~dst in root!

Best Answer

Dont try to use an absolute file path on the destination, the default is home.

Leave the path off to place it in home:

rsync /src user@server:

Or use a relative path to place it somewhere relative to home

rsync /src user@server:srccopy

Note you dont need --rsh=ssh either as its the default.

EDIT:
If you wish to copy into the home directory of a user that isnt the one youre logging into the remote machine with, you need to escape the ~ with quotes or a backslash. For example

rsync /src user@server:\~otheruser/
Related Topic