--- /dev/null
+readbuffer
+writebuffer
# with this program; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-CC=gcc
-CFLAGS=-Wall -Wwrite-strings -Wmissing-prototypes -Wstrict-prototypes -Wpointer-arith -O2 -g
+CC= gcc
+CFLAGS= $(WARNINGS) $(OPTIMISE) $(DEBUG)
+CPPFLAGS= -DRWBUFFER_SIZE_MB=$(RWBUFFER_SIZE_MB)
+
+WARNINGS= -Wall -Wwrite-strings -Wmissing-prototypes \
+ -Wstrict-prototypes -Wpointer-arith
+OPTIMISE= -O2
+DEBUG= -g
+RWBUFFER_SIZE_MB=16
+
+prefix=/usr/local
+etcdir=/etc/chiark-backup
+bindir=$(prefix)/bin
+sharedir=$(prefix)/share/chiark-backup
+
+INSTALL= install
+INSTALL_SHARE= $(INSTALL) -m 644 -o root -g root
+INSTALL_SCRIPT= $(INSTALL) -m 755 -o root -g root
+INSTALL_PROGRAM= $(INSTALL_SCRIPT) -s
+INSTALL_DIRECTORY= $(INSTALL) -m 2755 -o root -g root -d
+
+CTARGETS= readbuffer writebuffer
+BINSCRIPTS= checkallused loaded driver takedown whatsthis
+SHARESCRIPTS= bringup full increm
+SHAREFILES= backuplib.pl
+
+all: $(CTARGETS)
+
+install: all
+ $(INSTALL_DIRECTORY) $(etcdir) $(bindir) $(sharedir)
+ $(INSTALL_PROGRAM) $(CTARGETS) $(bindir)
+ set -e; for s in $(BINSCRIPTS); do \
+ $(INSTALL_SCRIPT) $$s $(bindir)/backup-$$s; done
+ $(INSTALL_SHARE) $(SHAREFILES) $(sharedir)
+
+clean:
+ rm -f *~ ./#*#
+
+distclean realclean: clean
+ rm -f $(CTARGETS)
# incremental dumps or listed as exceptions.
BEGIN {
- $etc= '/etc/backup';
+ $etc= '/etc/chiark-backup';
require "$etc/settings.pl";
require 'backuplib.pl';
}
# with this program; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-cd /var/local/backup
-PATH=/usr/local/lib/backup:$PATH export PATH
+cd /var/lib/chiark-backup
+PATH=/usr/lib/chiark-backup:$PATH export PATH
if [ "x$1" != test ]; then
stty sane
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
BEGIN {
- $etc= '/etc/backup';
+ $etc= '/etc/chiark-backup';
require "$etc/settings.pl";
require 'backuplib.pl';
}
# includes ID and function).
BEGIN {
- $etc= '/etc/backup';
+ $etc= '/etc/chiark-backup';
require "$etc/settings.pl";
require 'backuplib.pl';
}
places (the paths can probably be configured/hacked, but this is
where they are on my system and on chiark):
-etc.tgz : /etc/backup/
+etc.tgz : /etc/chiark-backup/
lib.tgz : /usr/local/lib/backup/
-var.tgz : /var/local/backup/
+var.tgz : /var/lib/chiark-backup/
NOTE: these versions are not those used on chiark; they
are somewhat modified by me (couple of extra features and
You'll also need to recompile readbuffer and writebuffer unless
you're using SPARClinux :->
-Contents of /etc/backup/:
+Contents of /etc/chiark-backup/:
warnings.* : files defining how many warnings you get as the
system is brought down to do backups. The defaults are fine.
settings.pl : generic config file: in particular, the name of
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
set -e
-cd /var/local/backup
+cd /var/lib/chiark-backup
-if test -f "/etc/backup/tape.$1"
+if test -f "/etc/chiark-backup/tape.$1"
then
echo "$1" >really-TAPEID
echo "Will assume tape is $1 unless I discover otherwise."
else
+ if [ "x$1" != x ]; then echo "Tape $1 not found."; fi
echo "Will only use tape if it has a TAPEID."
rm -f really-TAPEID
fi
#include <sys/time.h>
#include <sys/types.h>
+#include <sys/mman.h>
#include <assert.h>
#include <fcntl.h>
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
-#define BUFFER 16*1024*1024
+#ifndef RWBUFFER_SIZE_MB
+#define RWBUFFER_SIZE_MB 16
+#endif
+
+#define BUFFER (RWBUFFER_SIZE_MB*1024*1024)
#define WAITEMPTY ((BUFFER*1)/4)
static inline int min(int a, int b) { return a<=b ? a : b; }
-# configuration, for putting in /etc/backup
+# configuration, for putting in /etc/chiark-backup
-chdir '/var/local/backup' or die $!;
-push(@INC,'/usr/local/lib/backup');
-$ENV{'PATH'} =~ s,^/usr/local/lib/backup:/usr/local/bin:,,;
-$ENV{'PATH'}= '/usr/local/lib/backup:/usr/local/bin:'.$ENV{'PATH'};
+chdir '/var/lib/chiark-backup' or die $!;
+push(@INC,'/usr/lib/chiark-backup');
+$ENV{'PATH'} =~ s,^/usr/lib/chiark-backup,,;
+$ENV{'PATH'}= '/usr/lib/chiark-backup:'.$ENV{'PATH'};
# This sets both blocksizes to 512b. Note that both must be the
# same if using the zftape floppy tape driver, since that requires
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# Expects a single (possibly empty) argument X which is used to select
-# a file /etc/backup/warnings.X. This file will contain lines like:
+# a file /etc/chiark-backup/warnings.X. This file will contain lines like:
# T 300 "in 10 minutes"
# T 240 "in 5 minutes"
# T 45 "in 1 minute"
# takedown now no warning at all
set -e
-cd /etc/backup
+cd /etc/chiark-backup
host="`hostname`" || true
sub rewind();
sub stopandsay(@);
-$etc='/etc/backup';
+$etc='/etc/chiark-backup';
require "$etc/settings.pl";
require 'backuplib.pl';
# Now back up so we can read the file again properly
#system "mt -f $ntape bsf 1"; $? and stopandsay "couldn't backspace tape: $?";
-system "dd if=$ntape ibs=$blocksizebytes | /usr/local/lib/backup/readbuffer | $reader";
+system "dd if=$ntape ibs=$blocksizebytes | readbuffer | $reader";
$? and stopandsay "listing failed: $?";
# All's well, stop here.
#include <errno.h>
#include <unistd.h>
-#define BUFFER 16*1024*1024
+#ifndef RWBUFFER_SIZE_MB
+#define RWBUFFER_SIZE_MB 16
+#endif
+
+#define BUFFER (RWBUFFER_SIZE_MB*1024*1024)
#define WAITFILL ((BUFFER*3)/4)
static inline int min(int a, int b) { return a<=b ? a : b; }
int main(int argc, const char *const *argv) {
static unsigned char buf[BUFFER];
- if (argv[1]) {
- fputs("readbuffer: no arguments allowed\n", stderr);
- exit(-1);
- }
-
unsigned char *wp, *rp;
int used,r,writing,seeneof;
fd_set readfds;
fd_set writefds;
+ if (argv[1]) {
+ fputs("readbuffer: no arguments allowed\n", stderr);
+ exit(-1);
+ }
+
used=0; wp=rp=buf; writing=0; seeneof=0;
nonblock(0); nonblock(1);
while (!seeneof || used) {
--- /dev/null
+Source: chiark-utils
+Section: admin
+Priority: extra
+Maintainer: Ian and others <chiark-utils-maint@davenant.greenend.org.uk>
+Standards-Version: 2.1.1.0
+
+Package: chiark-backup
+Architecture: all
+Depends: chiark-rwbuffer
+Description: backup system for small systems and networks
+ These are the backup scripts used by chiark.greenend.org.uk and other
+ systems belonging to the Sinister Greenend Organisation. Features:
+ * Suitable for single systems and small networks.
+ * Reasonably simple; they do what you tell it to.
+ * Hard failures when individual systems fail, to encourage fixing !
+ If you have a larger site you may wish to look at Amanda.
+
+Package: chiark-rwbuffer
+Architecture: any
+Depends: ${shlibs:Depends}
+Description: readbuffer/writebuffer: prevents tape drive seesawing, etc.
+ readbuffer and writebuffer: programs for reading input from devices,
+ and writing output to, which don't like constant stopping and
+ starting, such as tape drives and audio playback devices.
--- /dev/null
+#!/usr/bin/make -f
+
+package= chiark-utils
+packages_indep= chiark-backup chiark-rwbuffer
+packages_arch= chiark-backup chiark-rwbuffer
+packages= $(packages_indep) $(packages_arch)
+
+cwd= $(shell pwd)
+d= $(cwd)/debian
+t= $d/tmp
+
+build:
+ $(checkdir)
+ $(MAKE) -C backup all
+ touch build
+
+clean:
+ $(checkdir)
+ -rm -f build
+ -$(MAKE) -i distclean || $(MAKE) -f Makefile.in distclean
+ -rm -rf *~ debian/tmp debian/*~ debian/files* debian/substvars*
+
+binary-prep:
+ $(checkdir)
+ -rm -rf debian/tmp*
+ -#
+ set -e; for p in $(packages); do \
+ install -d $t/$$p/DEBIAN $t/usr/share/doc/$$p; \
+ cp debian/copyright debian/changelog \
+ $t/$$p/usr/share/doc/$$p; \
+ ln -s changelog.gz $t/usr/share/doc/$$p/changelog.Debian.gz; \
+ gzip -9v $t/usr/share/doc/$$p/changelog; \
+ done
+ -#
+ $(MAKE) -C backup install prefix=$t/chiark-backup
+ -#
+ install -d $t/chiark-rwbuffer/usr/bin
+ cd $t/chiark-backup/usr/bin && \
+ mv readbuffer writebuffer $t/chiark-rwbuffer/usr/bin
+
+binary-hook-chiark-backup:
+binary-hook-chiark-rwbuffer:
+
+binary-one:
+ dpkg-gencontrol -p$p -O$t/$p -Tdebian/sv-$p
+ chown -R root.root debian/tmp
+ chmod -R g-ws debian/tmp
+ debian/rules binary-hook-$p
+ dpkg --build $t/$p ..
+
+binary-indep: checkroot build binary-prep
+ install -d debian/tmp/var/run/$(package)/
+ cp debian/{postinst,prerm,postrm,conffiles} debian/tmp/DEBIAN/.
+ cp debian/initd debian/tmp/etc/init.d/userv
+ chmod +x debian/tmp/DEBIAN/{postinst,prerm,postrm}
+ chmod +x debian/tmp/etc/init.d/userv
+ $(MAKE) LDFLAGS=-s INSTALL_PROGRAM='install -c -s' \
+ prefix=debian/tmp/usr etcdir=debian/tmp/etc \
+ docdir=debian/tmp/usr/doc/userv \
+ install install-doc
+ cp debian/copyright debian/tmp/usr/doc/$(package)/.
+ cp debian/changelog debian/tmp/usr/doc/$(package)/changelog
+ cp README debian/tmp/usr/doc/$(package)/README.upstream
+ cp system.default system.override debian/tmp/usr/doc/$(package)/examples
+ ln -s changelog.gz debian/tmp/usr/doc/$(package)/changelog.Debian.gz
+ gzip -9v debian/tmp/usr/doc/$(package)/changelog debian/tmp/usr/man/man1/*.1
+ rm debian/tmp/usr/doc/userv/*.ps
+ dpkg-shlibdeps daemon client
+ dpkg-gencontrol
+ chown -R root.root debian/tmp
+ chmod -R g-ws debian/tmp
+ chmod 700 debian/tmp/var/run/userv
+ dpkg --build debian/tmp ..
+ $(checkdir)
+
+binary-arch: checkroot build binary-prep
+ $(checkdir)
+ rm debian/tmp/usr/doc/userv/*.ps
+ dpkg-shlibdeps -Tdebian/sv-chiark-backup $t/chiark-backup/usr/bin/*
+ set -e; for p $(packages_arch); do debian/rules binary-one p=$$p; done
+
+define checkdir
+ test -f backup/writebuffer.c
+endef
+
+# Below here is fairly generic really
+
+binary: binary-indep binary-arch
+
+source diff:
+ @echo >&2 'source and diff are obsolete - use dpkg-source -b'; false
+
+checkroot:
+ $(checkdir)
+ test root = "`whoami`"
+
+.PHONY: binary binary-arch binary-indep clean checkroot