1
0

restore 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. #!/bin/rc
  2. # restore arena# [dev] - load venti with arenas on dev, stored one per track
  3. # starting with arena#. must have run fmtarenas before restoring
  4. # the first arena in the partition.
  5. # this must be run on the venti server, without venti running on the
  6. # affected arena partition(s).
  7. rfork ne
  8. if (test -e /sys/lib/backup/funcs)
  9. . /sys/lib/backup/funcs
  10. switch ($#*) {
  11. case 1
  12. case 2
  13. rdev=$2
  14. case *
  15. echo usage: $0 arena-num '[dev]' >[1=2]
  16. exit usage
  17. }
  18. starena=$1
  19. if (! ~ $starena [0-9] [0-9][0-9] [0-9][0-9][0-9]) {
  20. echo $0: bad starting arena: $starena >[1=2]
  21. exit bad-arena-num
  22. }
  23. # clear any dregs from a previous run
  24. unmount /mnt/cd >[2]/dev/null
  25. sleep 1
  26. kill cdfs | rc
  27. sleep 1
  28. cdfs -d $rdev || exit
  29. cd /mnt/cd
  30. #for (track in d[0-9]*)
  31. # venti/wrarena $track # slow; takes about 12½ mins. per GB
  32. arena = $starena
  33. # set arenabase for arenastart
  34. arenabase = `{ venti/printarenapart $arenas | sed -e 's/.*arenabase=//' -e 1q }
  35. kill printarenapart | rc # printarenapart leaves a process behind
  36. # echo arenabase $arenabase
  37. skipping=yes
  38. for (track in d[0-9]*) {
  39. if (~ track 'd[0-9]*') {
  40. echo $0: no tracks in /mnt/cd >[1=2]
  41. exit no-tracks
  42. }
  43. if (~ $skipping yes) {
  44. # verify that first track is the expected one
  45. type=`{file $track}
  46. switch ($"type) {
  47. case *': venti arena'
  48. name=`{ venti/printarena $track >[2=1] |
  49. sed -e 's/.*name=([^ =]+).*/\1/' -e 1q }
  50. case *
  51. name=NOT-A-VENTI-ARENA
  52. }
  53. kill printarena | rc # printarena leaves a process behind
  54. echo -n first track is $"name'; is that right? '
  55. switch (`{read}) {
  56. case [yY]*
  57. skipping=no
  58. case skip
  59. skipping=yes
  60. case *
  61. echo aborting, arena is unchanged. >[1=2]
  62. exit 'wrong track'
  63. }
  64. }
  65. if (! ~ $skipping yes) {
  66. # copy each track into its slot in the arena partition
  67. venti/printarena $track >[2=1] | sed 1q | tr -d '\12'
  68. kill printarena | rc # printarena leaves a process behind
  69. off = `{arenastart $arena}
  70. # echo -n writing $track to $arenas at 8K-block offset $off:
  71. sleep 3
  72. echo
  73. # argh! something (cdfs?) appends 60K of *stuff* to each
  74. # arena on optical disc. restrain dd.
  75. count=`{ echo $arenasize/$blocksize | bc }
  76. pump -i 1048576 -o 65536 -d 10 <$track |
  77. dd -quiet 1 -count $count -bs $blocksize -of $arenas \
  78. -oseek $off
  79. arena = `{hoc -e $arena+1}
  80. }
  81. }
  82. # when all done, must run venti/checkarenas, fmtisect, fmtbloom, fmtindex,
  83. # and (the big one) venti/buildindex -b /cfg/pie/venti.conf