6 echo 'usage: replica/pull [-nv] [-c name] [-s name] replica-name [paths]' >[1=2]
10 . /rc/bin/replica/defs $*
12 need clientlog serverlog clientdb clientroot serverroot
14 # mount the server file system, update the log
20 n=`{ls -l $clientlog >[2]/dev/null |awk '{print $6}'}
21 s=`{ls -l $serverlog >[2]/dev/null |awk '{print $6}'}
22 if(~ $n 0 || ~ $#n 0 || test $s -lt $n){
23 if(test -e $clientlog) must rm $clientlog
24 must fcp $serverlog $clientlog
27 m=`{echo $n-1024 | hoc}
30 cmp -s $serverlog $clientlog $m $m
34 must tail +^$n^c $serverlog >>$clientlog
37 must fcp $serverlog $clientlog
45 # normally we'd do this after applylog, but we want
46 # applylog to be the last thing in this script, so we'll
47 # do it here instead, compacting changes from the
50 ndb=`{echo $clientdb | sed 's;(.*)/(.*);\1/_\2;'}
51 must replica/compactdb $clientdb >$ndb
54 # mount the client file system, apply the log
55 # this is the last thing in the script and is execed so that
56 # if replica/pull is overwritten nothing bad will happen.
57 # applylog takes care of itself as far as protection against being overwritten.
58 exec replica/applylog $opt $applyopt $clientdb $clientroot $serverroot $paths <$clientlog