Why rsync uses mkdir without p option

z3ple picture z3ple · Dec 21, 2012 · Viewed 16.8k times · Source

As I can see rsync can't sync file if some of directories in file path doesn't exist. Why it doesn't create this directories with mkdir -p command? Maybe it has an option for that? -r option doesn't work in that case.

Answer

Michael Hasan picture Michael Hasan · Dec 21, 2012

Somebody asked a similar question here:

rsync: how can I configure it to create target directory on server?

It doesn't look like rsync is able to do that. You would have to write a wrapper script that does a mkdir -p on the target directory before executing rsync. If your target directory is on a different server, you might be able to run the mkdir -p command in a script through ssh.