chiark / gitweb /
Portability fix: Fix on libcs where st_mtime is not a macro (ie, ones lacking st_mtim.)
[chiark-utils.git] / backup / full
index a46726077e414ff1275606931562672a82b4024c..61b62668ef47ba249ad1924690a6674c68786328 100755 (executable)
@@ -6,12 +6,13 @@
 # other UN*X-compatible machines, as used on chiark.greenend.org.uk.
 #
 # chiark backup is:
-#  Copyright (C) 1997-1998,2000-2001 Ian Jackson <ian@chiark.greenend.org.uk>
+#  Copyright (C) 1997-1998,2000-2001,2007
+#                     Ian Jackson <ian@chiark.greenend.org.uk>
 #  Copyright (C) 1999 Peter Maydell <pmaydell@chiark.greenend.org.uk>
 #
 # 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
@@ -19,8 +20,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.
 
 BEGIN {
     $etc= '/etc/chiark-backup';
@@ -161,7 +162,7 @@ unlink 'this-md5sums';
 print "Doing $doing ...\n" or die $!;
 
 unlink 'p';
-system 'mknod p p'; $? and die $?;
+system 'mknod -m600 p p'; $? and die $?;
 
 setstatus "FAILED during dump";
 
@@ -186,6 +187,7 @@ foreach $exc (@excl) {
 for $tf (@fsys) {
     printdate();
     parsefsys();
+    prepfsys();
 
     pipe(FINDOR,FINDOW) or die $!;
     pipe(DUMPOR,DUMPOW) or die $!;
@@ -203,12 +205,13 @@ for $tf (@fsys) {
        $ddcmd .= " conv=sync";
     }
     
-    nexttapefile("full $prefix:$atf");
+    nexttapefile("full $prefix:$atf_print");
 
     # We can back up via dump or cpio or zafio
     $dumpin= '</dev/null';
     if ($tm eq 'dump') {
-       $dumpcmd= "dump 0bfu $softblocksizekb - $atf";
+       $dumplabel= $pcstr.$atf_print.'$';
+       $dumpcmd= "dump 0Lbfu $dumplabel $softblocksizekb - $atf";
     } elsif ($tm eq 'cpio') {
        startprocess '</dev/null','>&FINDOW',$rstr."find $atf -xdev -noleaf -print0";
        $dumpcmd= "cpio -Hustar -o0C$softblocksizebytes";
@@ -221,8 +224,11 @@ for $tf (@fsys) {
         $dumpin = '<&FINDOR';
     } elsif ($tm eq 'ntfsimage') {
        $dumpcmd= "ntfsimage -svvf --dirty $dev";
+    } elsif ($tm eq 'gtar') {
+       execute("$rstr touch $fsidfile+new");
+       $dumpcmd= "tar Ccfl $atf - .";
     } else {
-       die "unknown method $tm for $prefix:$atf\n";
+       die "unknown method $tm for $prefix:$atf_print\n";
     }
     # This is a funky way of doing a pipeline which pays attention
     # to the exit status of all the commands in the pipeline.
@@ -249,6 +255,12 @@ for $tf (@fsys) {
     push @tapefilesizes, [ $1, $currenttapefilename ];
     $totalrecords += $1;
     pboth("total blocks written so far: $totalrecords\n");
+
+    if ($tm eq 'gtar') {
+       execute("$rstr mv -f $fsidfile+new $fsidfile");
+    }  
+    
+    finfsys();
 }
 
 # The backup should now be complete; verify it