[clug] rsync -r --max-depth=2
Robert Edwards
bob at cs.anu.edu.au
Fri Aug 31 06:28:25 GMT 2007
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
>
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