dump-remind.in 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. #!/bin/sh
  2. # This file is included in the GNU tar distribution as an example. It is
  3. # not used by default unless the proper line is uncommented in backup-specs.
  4. # System administrators will probably want to customize this and
  5. # backup-specs for their site.
  6. #
  7. # This script should be run by tar with --info-script (-F) to inform
  8. # interested parties that a tape for the next volume of the backup needs to
  9. # be put in the tape drive.
  10. # Copyright 2004-2023 Free Software Foundation, Inc.
  11. # This file is part of GNU tar.
  12. # GNU tar is free software; you can redistribute it and/or modify
  13. # it under the terms of the GNU General Public License as published by
  14. # the Free Software Foundation; either version 3 of the License, or
  15. # (at your option) any later version.
  16. # GNU tar is distributed in the hope that it will be useful,
  17. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. # GNU General Public License for more details.
  20. # You should have received a copy of the GNU General Public License
  21. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  22. # Include location of 'sendmail' and GNU finger.
  23. PATH="/usr/lib:/usr/local/gnubin:${PATH}"
  24. export PATH
  25. # Load library routines
  26. SYSCONFDIR=${SYSCONFDIR-@sysconfdir@}
  27. . ${LIBPATH-@libexecdir@}/backup.sh
  28. MT_REWIND
  29. MT_OFFLINE
  30. # Get a list of people to whom to mail a request for changing the tape.
  31. # This egregious nightmare parses the output from GNU finger which shows
  32. # which users are logged into consoles (and thus in the office and capable
  33. # of changing tapes).
  34. #
  35. # Certain users (like 'root') aren't real users, and shouldn't be notified.
  36. # Neither should 'zippy', 'elvis', etc. (on the GNU machines) since they're
  37. # just test accounts.
  38. recipients="`
  39. finger .clients 2> /dev/null \
  40. | sed -ne '
  41. 1{
  42. /clientstatus: file has not changed in/{
  43. n;n;n;n;d
  44. }
  45. n;n;d
  46. }
  47. s/^..................................................//
  48. $!{/^$/d
  49. /^root?*$/d
  50. /^zippy$/d
  51. /^fnord$/d
  52. /^elvis$/d
  53. /^snurd$/d
  54. H
  55. }
  56. ${g
  57. : 1
  58. s/\(\n\)\([A-Za-z0-9_][A-Za-z0-9_]*\)\(\n.*\)\2\(.*\)/\1\2\3\4/g
  59. s/\n$//g
  60. t 1
  61. s/^\n//
  62. s/\n$//g
  63. s/\n/, /g
  64. : 2
  65. s/, ,/,/g
  66. t 2
  67. p
  68. }'`"
  69. # Customized behavior for FSF machines, to bring attention to the fact that
  70. # the tape needs to be changed (who looks at the terminal?)
  71. sendmail -oi -t << __EOF__
  72. From: `basename $0` (backup tape-changing reminder)
  73. To: ${recipients}
  74. Cc: ${ADMINISTRATOR}
  75. Subject: Backup needs new tape for volume ${TAR_VOLUME}
  76. Reply-To: ${ADMINISTRATOR}
  77. This is an automated report from the backup script running on
  78. `hostname`.
  79. Volume ${TAR_VOLUME} of the backup needs to be put in the tape drive.
  80. Usually whoever prepared the backup leaves labeled tapes on top of the
  81. drive itself. If there aren't any more, information about where to find
  82. tapes and how to label them are posted on the wall by apple-gunkies
  83. (unhelpfully obscured by a bookshelf). An online copy (which is probably
  84. more up-to-date) can also be found in ~friedman/etc/fsf/backup.how.
  85. __EOF__
  86. echo "Please put volume ${TAR_VOLUME} in tape drive and press RETURN"
  87. read input
  88. echo "Writing volume ${TAR_VOLUME}..."
  89. sendmail -oi -t << __EOF__
  90. From: `basename $0` (backup tape-changing reminder)
  91. To: ${recipients}
  92. Cc: ${ADMINISTRATOR}
  93. Subject: Volume ${TAR_VOLUME} for backup has been added
  94. Reply-To: ${ADMINISTRATOR}
  95. This is an automated report from the backup script running on
  96. `hostname`.
  97. The backup has been continued, so for now no further attention is required.
  98. __EOF__
  99. exit 0
  100. # eof