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
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
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)
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: $!";
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";
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';
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:
--- /dev/null
+#!/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= <T>);
+ 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;
--- /dev/null
+.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)
--- /dev/null
+.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)
+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.
$(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: