4
0

dump-remind.in 3.8 KB

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