How to Rsync Over SSH When Directory Names Have Spaces

rsyncssh

I am trying to rsync from one server to another. The servers have the same directory structure but I am having trouble getting the remotes server to properly recognize the path name on the remote when there is a space in it.

Here are the details

The local directory is

mnt/xlses/split/v2/name with space

The remote directory is

mnt/xlses/split/v2/name with space

I have tried everything I can find the latest attempt was

rsync --size-only -avzPe ssh  /mnt/xlses/split/v2/name\ with\ space/ root@myserver.com:/mnt/xlses/split/v2/"name with space"

when that runs the first thing it reports is that it is creating a new directory

I interrupt it and see that there is a new directory

mnt/xlses/split/v2/name

all of my files are in that directory

I was expecting them to be in

mnt/xlses/split/v2/name with space

Best Answer

Try

rsync --size-only -avzPe ssh /mnt/xlses/split/v2/name\ with\ space root@myserver.com:/mnt/xlses/split/v2/

I took off the trailing slash / from the source directory path. This will make rsync copy the directory and all its contents, which means rsync will worry about getting the name correct on the remote host (which it will) instead of you.

Related Question