creating directories on destination

Pete Mocat kyo23 at
Sun Mar 16 19:59:51 EST 2003


I need some advice on having rsync automatically create directories on the 
destination server

I have the following directory structure:

source host:




On the destination host (host_name) I have:


and I want to backup the source host to this dir so that at the end of the 
backup I have:


I am using:

/usr/bin/rsync -qaze ssh /home/user1/ 
root at host_name:/home/backups/host_name/home/user1

(I call this for all other dirs too of course, see my next
message for why I do not just backup /home/ all at once)

With this command line, rsync fails unless I first:

mkdir /home/backups/host_name/home/
mkdir -p /home/backups/host_name/var/lib/mysql

Is there a way to have rsync create those directories if they do not exist?

My goal is to be able to put the backup script onto a new source server and 
(assuming it has root access to the destination server), start making 
backups without any setup on the destination server.

This is not just out of laziness either :) I want the backups to be bullet 
proof so I want to cover the case where the backup server gets hosed and 
looses the parent dirs, etc. I want the next run of the backups to recreate 
all needed dirs.

I realize I can do this with a script that ssh's to the server and runs the 
mkdir's for me on each invocation of the backup script but I am interested 
if rsync can do this for me just for the sake of clean-ness and simplicity.


Tired of spam? Get advanced junk mail protection with MSN 8.

More information about the rsync mailing list