[clug] rsync -r --max-depth=2

Robert Edwards bob at cs.anu.edu.au
Fri Aug 31 06:52:26 GMT 2007


Robert Edwards wrote:
> Michael James wrote:
>> I need to pull a mirror of the home dirs on an rsync server.
>> Because it's a huge job I normally run a script
>>  that does an rsync for each user.
>>
>> When it happens locally the script starts like this:
>> cd /home
>> for $dir in `ls -1 */*`
>> do
>>     test -d "/back/$dir" || mkdir /back/$dir
>>     rsync  -a   /home/${dir}/   /back/${dir}/
>> done
>>
>> From a remote rsync server I can't do shell globbing.
>> So if a new user is added , the mirror will never get to know about it.
>>
>> Is there any option on rsync that will accomplish this:
>>
>> rsync -ra --maxdepth=2 server::home/ /mirror/
>> cd /mirror
>> for $dir in `ls -1 */*`
>> do
>>     rsync -a  server::home/${dir}/   /back/${dir}/
>> done
>>
>> <Wonders>  Can  "-d"  be encoraged to pull an unnamed dir?
>>
>> TIA,
>> michaelj
>>

Woops, I see that you are trying to "pull" the backup from the
backup server, rather than "push" it to the backup server.

Sorry, misread your post.

We always "push" to the backup server, so I can't comment on
your application.

Cheers,

Bob Edwards.
> 
> How about:
> 
> cd /home
> for $dir in `ls -1 */*`
> do
>     test -d "/back/$dir" || mkdir /back/$dir
>     rsync -a /home/${dir} /back/
> done
> 
> Bob Edwards.



More information about the linux mailing list