From 470ba2e9de232758429e7656cfecb18edffabbfa Mon Sep 17 00:00:00 2001 From: ianmdlvl Date: Fri, 9 Nov 2001 21:12:19 +0000 Subject: [PATCH] @@ -1,3 +1,11 @@ +chiark-utils (2.1.0) experimental; urgency=low + + * man pages for readbuffer, writebuffer from Richard Kettlewell. + * add info re last-tape and checkallused to iwjbackup.txt. + * new `backup-labeltape' utility. + + -- + chiark-utils (2.0.0) experimental; urgency=low * Initial prepackaged release of chiark backup. --- backup/Makefile | 8 ++++++-- backup/backuplib.pl | 19 +++++++++++++++++++ backup/full | 12 +++--------- backup/iwjbackup.txt | 4 ++++ backup/labeltape | 43 +++++++++++++++++++++++++++++++++++++++++++ backup/readbuffer.1 | 24 ++++++++++++++++++++++++ backup/writebuffer.1 | 25 +++++++++++++++++++++++++ debian/changelog | 8 ++++++++ debian/rules | 7 ++++++- 9 files changed, 138 insertions(+), 12 deletions(-) create mode 100755 backup/labeltape create mode 100644 backup/readbuffer.1 create mode 100644 backup/writebuffer.1 diff --git a/backup/Makefile b/backup/Makefile index 3b55957..207766f 100644 --- a/backup/Makefile +++ b/backup/Makefile @@ -41,6 +41,8 @@ sharedir=$(prefix)/share/chiark-backup txtdocdir=$(prefix)/share/doc/chiark-backup exampledir=$(txtdocdir)/examples vardir=$(varlib)/chiark-backup +mandir=${prefix}/man +man1dir=${mandir}/man1 INSTALL= install -c INSTALL_SHARE= $(INSTALL) -m 644 -o root -g root @@ -49,7 +51,7 @@ INSTALL_PROGRAM= $(INSTALL_SCRIPT) -s INSTALL_DIRECTORY= $(INSTALL) -m 2755 -o root -g root -d CTARGETS= readbuffer writebuffer -BINSCRIPTS= checkallused loaded driver takedown whatsthis +BINSCRIPTS= checkallused loaded driver takedown whatsthis labeltape SHARESCRIPTS= bringup full increm SHAREFILES= backuplib.pl @@ -62,12 +64,14 @@ writebuffer: writebuffer.o rwbuffer.o readbuffer.o writebuffer.o rwbuffer.o: rwbuffer.h install: all - $(INSTALL_DIRECTORY) $(confdir) $(bindir) $(sharedir) $(vardir) + $(INSTALL_DIRECTORY) $(confdir) $(bindir) $(sharedir) $(vardir) $(man1dir) $(INSTALL_PROGRAM) $(CTARGETS) $(bindir) set -e; for s in $(BINSCRIPTS); do \ $(INSTALL_SCRIPT) $$s $(bindir)/backup-$$s; done $(INSTALL_SHARE) $(SHAREFILES) $(sharedir) $(INSTALL_SCRIPT) $(SHARESCRIPTS) $(sharedir) + $(INSTALL) -m 644 readbuffer.1 ${man1dir}/readbuffer.1 + $(INSTALL) -m 644 writebuffer.1 ${man1dir}/writebuffer.1 install-docs: $(INSTALL_DIRECTORY) $(txtdocdir) diff --git a/backup/backuplib.pl b/backup/backuplib.pl index ba1c50b..8be8bff 100644 --- a/backup/backuplib.pl +++ b/backup/backuplib.pl @@ -51,6 +51,25 @@ sub startprocess ($$$) { exec $c; die "$c: $!"; } +sub readtapeid_raw () { + open T, ">>TAPEID" or die $!; close T; + unlink 'TAPEID' or die $!; + system "mt -f $tape rewind"; $? and die $?; + system "mt -f $tape setblk $blocksizebytes"; $? and die $?; + system "dd if=$tape bs=${blocksize}b count=10 ". + "| tar -b$blocksize -vvxf - TAPEID"; +} + +sub writetapeid ($) { + open T, ">TAPEID" or die $!; + print T "$_[0]\n" or die $!; + close T or die $!; + + system "tar -b$blocksize -vvcf TAPEID.tar TAPEID"; $? and die $?; + system "dd if=TAPEID.tar of=$ntape bs=${blocksize}b count=10"; + $? and die $?; +} + sub endprocesses () { while (keys %processes) { $p= waitpid(-1,0) or die "wait: $!"; diff --git a/backup/full b/backup/full index 02b5b0c..0861537 100755 --- a/backup/full +++ b/backup/full @@ -41,10 +41,8 @@ printdate(); setstatus "FAILED reading TAPEID"; # Try to read the tape ID from the tape into the file TAPEID -unlink 'TAPEID'; -system "mt -f $tape rewind"; $? and die $?; -system "mt -f $tape setblk $blocksizebytes"; $? and die $?; -system "dd if=$tape bs=${blocksize}b count=10 | tar -b$blocksize -vvxf - TAPEID"; + +readtapeid_raw(); setstatus "FAILED during startup"; @@ -132,12 +130,8 @@ print LOG "$doing:\n" or die $!; setstatus "FAILED writing tape ID"; # First write the tape ID to this tape. -open T, ">TAPEID" or die $!; -print T "$tapeid\n" or die $!; -close T or die $!; -system "tar -b$blocksize -vvcf TAPEID.tar TAPEID"; $? and die $?; -system "dd if=TAPEID.tar of=$ntape bs=${blocksize}b count=10"; $? and die $?; +writetapeid($tapeid); unlink 'this-md5sums'; diff --git a/backup/iwjbackup.txt b/backup/iwjbackup.txt index 91c904c..4ee2354 100644 --- a/backup/iwjbackup.txt +++ b/backup/iwjbackup.txt @@ -96,6 +96,10 @@ Useful scripts (all in /usr/bin): backup-checkallused: this only does a check of the configuration files. It should give a cryptic summary of the configuration and print 'configuration ok'. If not, fix your config files :-> +You have to create the file /var/lib/chiark-backup/last-tape +containing the id of a tape; this helps backup-checkallused know where +to start iterating over tapes. Any tapeid will do. (But don't make +it the same as the one you want to back up to first.) backup-loaded: this tells the scripts that a currently unlabelled tape should be treated as tape X: eg: diff --git a/backup/labeltape b/backup/labeltape new file mode 100755 index 0000000..98961af --- /dev/null +++ b/backup/labeltape @@ -0,0 +1,43 @@ +#!/usr/bin/perl + +use POSIX; + +$etc= '/etc/chiark-backup'; +require "$etc/settings.pl"; +require 'backuplib.pl'; + +while ($ARGV[0] =~ m/^-/) { + $_= shift @ARGV; + last if m/^\-$/; + s/^\-//; + while (length) { + if (s/^f//) { + $force=1; + } else { + die "$0: unknown option -$_\n"; + } + } +} + +@ARGV==1 or die "$0: need 1 arg, new TAPEID"; +($newid)= @ARGV; + +readtapeid_raw(); + +if (!open T,'TAPEID') { + $!==&ENOENT or die $!; +} else { + chomp($oldid= ); + close T or die $!; + print "Tape is currently labelled \`$oldid'\n" or die $!; + die "$0: use -f to force relabelling\n" unless $force; +} + +open T,'>TAPEID' or die $!; +print T "$newid\n" or die $!; +close T or die $!; + +writetapeid($newid); + +print "Labelled tape \`$newid'\n" or die $!; +exit 0; diff --git a/backup/readbuffer.1 b/backup/readbuffer.1 new file mode 100644 index 0000000..361faea --- /dev/null +++ b/backup/readbuffer.1 @@ -0,0 +1,24 @@ +.TH readbuffer 1 2001-10-21 chiark-backup +.SH NAME +readbuffer \- read input from devices which don't like constant stopping and starting +.SH SYNOPSIS +.B readbuffer +.RB [ --mlock ] +.RI [ size ] +.SH DESCRIPTION +.B readbuffer +reads data on standard input and writes it to standard output. It +will internally buffer up to \fIsize\fR megabytes of data, and will +only read more data when the buffer is at least 75% empty. +.PP +It is intended for use in situations where many small +reads are undesirable for performance reasons, e.g. tape drives. +.SH OPTIONS +.TP +.B --mlock +Calls +.BR mlock (2) +to lock the buffer into memory. +.SH "SEE ALSO" +.BR writebuffer (1), +.BR mlock (2) diff --git a/backup/writebuffer.1 b/backup/writebuffer.1 new file mode 100644 index 0000000..796ba93 --- /dev/null +++ b/backup/writebuffer.1 @@ -0,0 +1,25 @@ +.TH writebuffer 1 2001-10-21 chiark-backup +.SH NAME +writebuffer \- write output to devices which don't like constant stopping and starting +.SH SYNOPSIS +.B writebuffer +.RB [ --mlock ] +.RI [ size ] +.SH DESCRIPTION +.B writebuffer +reads data on standard input and writes it to standard output. It +will buffer internally up to \fIsize\fR megabytes and will only write +data when the buffer is at least 75% full or when there is no more +input to fill the buffer. +.PP +It is intended for use in situations where many small writes are +undesirable for performance reasons, e.g. tape drives. +.SH OPTIONS +.TP +.B --mlock +Calls +.BR mlock (2) +to lock the buffer into memory. +.SH "SEE ALSO" +.BR readbuffer (1), +.BR mlock (2) diff --git a/debian/changelog b/debian/changelog index 8e65459..3d7ad9c 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,11 @@ +chiark-utils (2.1.0) experimental; urgency=low + + * man pages for readbuffer, writebuffer from Richard Kettlewell. + * add info re last-tape and checkallused to iwjbackup.txt. + * new `backup-labeltape' utility. + + -- + chiark-utils (2.0.0) experimental; urgency=low * Initial prepackaged release of chiark backup. diff --git a/debian/rules b/debian/rules index 8265a3d..8cc2a66 100755 --- a/debian/rules +++ b/debian/rules @@ -40,11 +40,16 @@ binary-prep: $(MAKE) -C backup install install-docs install-examples \ prefix=$t/chiark-backup/usr \ etcdir=$t/chiark-backup/etc \ - varlib=$t/chiark-backup/var/lib + varlib=$t/chiark-backup/var/lib \ + mandir=$t/chiark-backup/usr/share/man # install -d $t/chiark-rwbuffer/usr/bin + install -d $t/chiark-rwbuffer/usr/share/man/man1 cd $t/chiark-backup/usr/bin && \ mv readbuffer writebuffer $t/chiark-rwbuffer/usr/bin + cd $t/chiark-backup/usr/share/man/man1 && \ + mv readbuffer.1 writebuffer.1 $t/chiark-rwbuffer/usr/share/man/man1 + gzip -9f $t/*/usr/share/man/man*/* binary-hook-chiark-backup: binary-hook-chiark-rwbuffer: -- 2.30.2