xref: /plan9/sys/src/cmd/venti/words/backup.example (revision 42d82305fbcd839fd6b81940f0fae5a107fcfc96)
1#!/bin/rc
2
3rfork e
4cd /usr/rsc
5. bkup.info
6fn x {
7	echo x $*
8	y=$1
9	if(~ $#$y 0){
10		$y=0
11	}
12	echo venti/wrarena -o $2 $3 $$y
13	end=`{venti/wrarena -o $2 $3 $$y | grep '^end offset ' | sed 's/^end offset //'}
14	if(~ $#end 1 && ! ~ $$y $end){
15		$y=$end
16		echo '#' `{date} >>bkup.info
17		whatis $y >>bkup.info
18	}
19}
20hget http://127.1:8000/index |
21awk '
22/^index=/ { blockSize=0+substr($3, 11); }
23/^arena=/ { arena=substr($1, 7); }
24/^	arena=/ { start=0+substr($5, 2)-blockSize; printf("x %s %d %s\n", arena, start, $3); }
25' |rc
26
27