X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?p=chiark-utils.git;a=blobdiff_plain;f=backup%2Fbackuplib.pl;h=cbbe6f4619b5612f248eb86cc70289ed6ab773dc;hp=ddeb5bbb4bd9b9243b80c33403fdd0223d732f1b;hb=10eb0f32b84cffb4267b32e496b577472ada4277;hpb=4ab01705d43752de160d2580489f8c3ac4014921 diff --git a/backup/backuplib.pl b/backup/backuplib.pl index ddeb5bb..cbbe6f4 100644 --- a/backup/backuplib.pl +++ b/backup/backuplib.pl @@ -5,12 +5,13 @@ # other UN*X-compatible machines, as used on chiark.greenend.org.uk. # # chiark backup is: -# Copyright (C) 1997-1998,2000-2001 Ian Jackson +# Copyright (C) 1997-1998,2000-2001,2007 +# Ian Jackson # Copyright (C) 1999 Peter Maydell # # This is free software; you can redistribute it and/or modify it under the # terms of the GNU General Public License as published by the Free Software -# Foundation; either version 2, or (at your option) any later version. +# Foundation; either version 3, or (at your option) any later version. # # This is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS @@ -18,8 +19,8 @@ # details. # # You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# with this program; if not, consult the Free Software Foundation's +# website at www.fsf.org, or the GNU Project website at www.gnu.org. require IO::File; @@ -173,8 +174,6 @@ sub parsefsys () { $dopts= $3; $prefix= ''; $pcstr= ''; - stat $atf or die "stat $atf: $!"; - -d _ or die "not a dir: $atf"; $rstr= ''; } elsif ($tf =~ m#^(/\S*)\s+(\w+)([,=0-9a-z]*)\s+(\w+)$#) { # Line of form '[/device:]/file/system dumptype[,options] prefix' @@ -197,11 +196,16 @@ sub parsefsys () { $dev = $atf =~ s,^(.*)\:,, ? $1 : ''; + if (!length $pcstr) { + stat $atf or die "stat $atf: $!"; + -d _ or die "not a dir: $atf"; + } + undef %dopt; foreach $dopt (split /\,/,$dopts) { - if (grep { $dopt eq $_ } qw(gz)) { + if (grep { $dopt eq $_ } qw(gz noinc)) { $dopt{$dopt}= 'y'; - if (grep { $dopt eq $_ } qw(snap)) { + } elsif (grep { $dopt eq $_ } qw(snap)) { $dopt{$dopt}= $dopt; } elsif ($dopt =~ m/\=/ && grep { $` eq $_ } qw(gz snap)) { $dopt{$`}= $'; @@ -222,6 +226,10 @@ sub parsefsys () { $$gzo= ''; } } + + if (length $dopt{'snap'}) { + length $dev or die "$pcstr:$atf no device but needed for snap"; + } } sub execute ($) { @@ -230,14 +238,19 @@ sub execute ($) { } sub prepfsys () { + $dev_print= $dev; + $atf_print= $atf; + if (length $dopt{'snap'}) { + system('snap-drop'); $? and die $?; $snapscripts= '/etc/chiark-backup/snap'; - $snapbase= "$rstr $snapscripts/$dopt{'snap'} /var/lib/chiark-backup"; + $snapbase= "$rstr $snapscripts/$dopt{'snap'}"; + $snapargs= "/var/lib/chiark-backup"; - $snapsnap= "$snapbase snap $dev $atf"; - $snapdrop= "$snapbase drop"; + $snapsnap= "$snapbase snap $snapargs $dev $atf"; + $snapdrop= "$snapbase drop $snapargs"; open SD, ">snap-drop.new" or die $!; print SD $snapdrop,"\n" or die $!;