Search code examples
rsync

Transferring a new folder to remote using rsync?


If I create a completely new folder locally, I want to be able to rsync it remotely to an SFTP server, how can I achieve this?

I have tried:

rsync Documents/SomeFolder username@host:/home/Documents/RemoteFolder

Meaning SomeFolder must go into RemoteFolder, but this doesn't work, instead it creates a file called SomeFolder

Would appreciate some help on this


Solution

  • If you use the -r (recurse into directories) option that should make it work. Also -d (transfer directories without recursing) will work. You should use -r if sometimes the folder will not be empty and you want to copy its contents. Use either as shown here:

    rsync -r Documents/SomeFolder username@host:/home/Documents/RemoteFolder