From 7d4185f54b99fef18f8661ea1d5974171f997f1e Mon Sep 17 00:00:00 2001 From: ianmdlvl Date: Sun, 21 Sep 2003 19:09:08 +0000 Subject: [PATCH 1/1] @@ -1,3 +1,9 @@ +chiark-utils (4.0.99.0.1) unstable; urgency=low + + * backup: new lvm/remount-ro snapshotting feature. + + -- + chiark-utils (4.0.0) unstable; urgency=medium New programs and utilities: --- backup/Makefile | 5 +- backup/backuplib.pl | 40 ++++++++++++-- backup/driver | 1 + backup/examples/chiark/settings.sh | 7 +++ backup/full | 3 ++ backup/increm | 3 ++ backup/iwjbackup.txt | 22 +++++--- backup/lvm | 84 ++++++++++++++++++++++++++++++ backup/remount | 30 +++++++++++ backup/snap-drop | 7 +++ debian/changelog | 6 +++ 11 files changed, 198 insertions(+), 10 deletions(-) create mode 100755 backup/examples/chiark/settings.sh create mode 100755 backup/lvm create mode 100755 backup/remount create mode 100755 backup/snap-drop diff --git a/backup/Makefile b/backup/Makefile index 91f7664..ce06cee 100644 --- a/backup/Makefile +++ b/backup/Makefile @@ -28,17 +28,20 @@ include ../settings.make BINSCRIPTS= checkallused loaded driver takedown whatsthis labeltape SHARESCRIPTS= bringup full increm SHAREFILES= backuplib.pl +SNAPKINDS= lvm remount EXAMPLES= relativity chiark all: install: all - $(INSTALL_DIRECTORY) $(confdir) $(bindir) $(sharedir) $(vardir) $(man1dir) + $(INSTALL_DIRECTORY) $(confdir) $(confdir)/snap $(bindir) \ + $(sharedir) $(vardir) $(man1dir) set -e; for s in $(BINSCRIPTS); do \ $(INSTALL_SCRIPT) $$s $(bindir)/backup-$$s; done $(INSTALL_SHARE) $(SHAREFILES) $(sharedir) $(INSTALL_SCRIPT) $(SHARESCRIPTS) $(sharedir) + $(INSTALL_SCRIPT) $(SNAPKINDS) $(confdir)/snap install-docs: $(INSTALL_DIRECTORY) $(txtdocdir) diff --git a/backup/backuplib.pl b/backup/backuplib.pl index 174dc81..1c6b64c 100644 --- a/backup/backuplib.pl +++ b/backup/backuplib.pl @@ -43,8 +43,7 @@ sub setstatus ($) { # used to implement the funky pipeline stuff. sub startprocess ($$$) { my ($i,$o,$c) = @_; - print LOG " $c\n" or die $!; - print " $c\n" or die $!; + pboth(" $c\n"); defined($p= fork) or die $!; if ($p) { $processes{$p}= $c; return; } open STDIN,"$i" or die "$c stdin $i: $!"; @@ -137,6 +136,8 @@ sub readfsysfile ($) { $prefix{$1}= $2; } elsif (m/^prefix\-df\s+(\w+)\s+(\S.*\S)$/) { $prefixdf{$1}= $2; + } elsif (m/^snap(?:\=(\w+))?\s+(\w+)\s+(\w+)$/) { + push @excldir,$1; } elsif (m/^excludedir\s+(\S.*\S)$/) { push @excldir,$1; } elsif (m/^exclude\s+(\S.*\S)$/) { @@ -195,7 +196,9 @@ sub parsefsys () { foreach $dopt (split /\,/,$dopts) { if (grep { $dopt eq $_ } qw(gz)) { $dopt{$dopt}= 'y'; - } elsif ($dopt =~ m/\=/ && grep { $` eq $_ } qw(gz)) { + if (grep { $dopt eq $_ } qw(snap)) { + $dopt{$dopt}= $dopt; + } elsif ($dopt =~ m/\=/ && grep { $` eq $_ } qw(gz snap)) { $dopt{$`}= $'; } elsif (length $dopt) { die "unknown option $dopt (in $dopts $tf)"; @@ -216,6 +219,37 @@ sub parsefsys () { } } +sub prepfsys () { + if (length $dopt{'snap'}) { + system('snap-drop'); $? and die $?; + + $snapscripts= '/etc/chiark-backup/snap'; + $snapbase= "$pcstr $snapscripts/$dopt{'snap'} /var/lib/chiark-backup"; + + $snapsnap= "$snapbase snap $dev $atf"; + $snapdrop= "$snapbase drop"; + + open SD, ">snap-drop.new" or die $!; + print SD $snapdrop,"\n" or die $!; + close SD or die $!; + rename "snap-drop.new","snap-drop" or die $!; + + pboth(" $snapsnap\n"); + system $snapsnap; $? and die $?; + + $dev_nosnap= $dev; + $atf_nosnap= $atf; + $dev= "/var/lib/chiark-backup/snap-device"; + $atf= "/var/lib/chiark-backup/snap-mount"; + } +} + +sub finfsys () { + if (length $dopt{'snap'}) { + system('snap-drop'); $? and die $?; + } +} + sub openlog () { unlink 'log'; $u= umask(007); diff --git a/backup/driver b/backup/driver index bdf3b38..36d9c1f 100755 --- a/backup/driver +++ b/backup/driver @@ -37,6 +37,7 @@ echo 'FAILED to start dump script' >this-status # both full and incremental backups, according to the ID of the # tape in the drive. full 2>&1 | tee this-log +snap-drop 2>&1 | tee this-log status=`cat this-status 2>/dev/null` diff --git a/backup/examples/chiark/settings.sh b/backup/examples/chiark/settings.sh new file mode 100755 index 0000000..06d5a97 --- /dev/null +++ b/backup/examples/chiark/settings.sh @@ -0,0 +1,7 @@ +# shell script fragment setting options +# defaults for currently implemented parameters are +#lvm_lv=chiark_backup +#lvm_lvsize_opts=-L +#lvm_lvtools_opts='-A n' +#lvm_lvcreate_opts= +#lvm_lvcreate_args= diff --git a/backup/full b/backup/full index a467260..9c603b9 100755 --- a/backup/full +++ b/backup/full @@ -186,6 +186,7 @@ foreach $exc (@excl) { for $tf (@fsys) { printdate(); parsefsys(); + prepfsys(); pipe(FINDOR,FINDOW) or die $!; pipe(DUMPOR,DUMPOW) or die $!; @@ -249,6 +250,8 @@ for $tf (@fsys) { push @tapefilesizes, [ $1, $currenttapefilename ]; $totalrecords += $1; pboth("total blocks written so far: $totalrecords\n"); + + finfsys(); } # The backup should now be complete; verify it diff --git a/backup/increm b/backup/increm index 57a037d..ac22095 100755 --- a/backup/increm +++ b/backup/increm @@ -88,6 +88,7 @@ setstatus "PROBLEMS during incremental dump"; for $tf (@fsys) { parsefsys(); + prepfsys(); $bufir='DUMPOR'; $ddcmd= "$nasty dd ibs=$softblocksizebytes obs=$blocksizebytes of=$ntape"; @@ -126,6 +127,8 @@ for $tf (@fsys) { # advance is a file counter, so it needs to be updated for each # dump we do to tape. $advance++; + + finfsys(); } # Rewind the tape, and increment the counter of incremental backups. diff --git a/backup/iwjbackup.txt b/backup/iwjbackup.txt index 5de4276..39000ee 100644 --- a/backup/iwjbackup.txt +++ b/backup/iwjbackup.txt @@ -15,6 +15,9 @@ brought down to do backups. The defaults are fine. settings.pl: generic config file: in particular, the name of the tape device is set here. +settings.sh: generic config file for shell scripts. Currently only +contains some options for the lvm snapshotter. + tape.*: conventionally, each tape you're going to use in the backup cycle has a tape number, a name and a config file. The tape numbers in use at Relativity are digit strings like `512'. The name is a @@ -69,12 +72,19 @@ volumes, requires device name). Only `dump' type backups perform incremental backups. is a comma-separated list of