tobackup 913 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #!/bin/rc
  2. # tobackup [set] - print names of venti arenas needing to be dumped to disc set
  3. rfork e
  4. cd /sys/lib/backup
  5. . funcs
  6. switch ($#*) {
  7. case 0
  8. case 1
  9. set=$1
  10. case *
  11. echo usage: $0 '[set]' >[1=2]
  12. exit usage
  13. }
  14. if (! test -d $set) {
  15. echo $0: no backup set named $set in $backup >[1=2]
  16. exit 'no backup set'
  17. }
  18. if (! hget -o index http://$fs/index) {
  19. echo $0: 'can''t fetch venti index from' $fs >[1=2]
  20. exit 'no venti index'
  21. }
  22. if (! test -s index) {
  23. echo $0: 'empty venti index from' $fs >[1=2]
  24. exit 'empty index'
  25. }
  26. cd $set
  27. awk '/^arena=/ { name=$1 }
  28. / disk=sealed/ { print name; name = "" }
  29. ' ../index | sed 's/^arena=//' >nsealed
  30. >>sealed
  31. if (! cmp -s sealed nsealed)
  32. cp nsealed sealed
  33. rm -f nsealed
  34. if (! test -s sealed)
  35. exit ''
  36. >>fake
  37. if (test -s ondisc)
  38. comm -23 <{sort -u sealed fake} <{sort -u ondisc}
  39. if not { # first sealed arenas, dump all
  40. cat sealed
  41. chmod +a ondisc >>ondisc
  42. }