chiark / gitweb /
palm-datebook-reminders ctime
[chiark-utils.git] / backup / backuplib.pl
index 50cc70a745f9aa070ed6778f12e3455c3df1303a..174dc812c9678320c53328e31c0ea0d50a05cfd0 100644 (file)
@@ -54,7 +54,7 @@ sub startprocess ($$$) {
 }
 
 sub rewind_raw () {
 }
 
 sub rewind_raw () {
-    system "mt -f $tape rewind"; $? and die $?;
+    runsystem("mt -f $tape rewind");
 }
 
 sub readtapeid_raw () {
 }
 
 sub readtapeid_raw () {
@@ -66,11 +66,34 @@ sub readtapeid_raw () {
           "| tar -b$blocksize -vvxf - TAPEID";
 }
 
           "| tar -b$blocksize -vvxf - TAPEID";
 }
 
+sub runsystem ($) {
+    pboth("    $_[0]\n");
+    system $_[0];
+    $? and die $?;
+}
+
+sub pboth ($) {
+    my ($str) = @_;
+    print LOG $str or die $!;
+    print $str or die $!;
+}
+
+sub nexttapefile ($) {
+    my ($what) = @_;
+    $currenttapefilenumber++;
+    $currenttapefilename= $what;
+    pboth(sprintf "writing tape file #%d (mt fsf %d): %s\n",
+         $currenttapefilenumber, $currenttapefilenumber-1, $what);
+}
+
 sub writetapeid ($$) {
     open T, ">TAPEID" or die $!;
     print T "$_[0]\n$_[1]\n" or die $!;
     close T or die $!;
 
 sub writetapeid ($$) {
     open T, ">TAPEID" or die $!;
     print T "$_[0]\n$_[1]\n" or die $!;
     close T or die $!;
 
+    $currenttapefilenumber= 0;
+    nexttapefile('TAPEID');
+
     system "tar -b$blocksize -vvcf TAPEID.tar TAPEID"; $? and die $?;
     system "dd if=TAPEID.tar of=$ntape bs=${blocksize}b count=10";
     $? and 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 $?;
@@ -84,8 +107,7 @@ sub endprocesses () {
        delete $processes{$p};
        $? && die "error: command gave code $?: $c\n";
     }
        delete $processes{$p};
        $? && die "error: command gave code $?: $c\n";
     }
-    print LOG "  ok\n" or die $!;
-    print "  ok\n" or die $!;
+    pboth("  ok\n");
 }
 
 sub killprocesses {
 }
 
 sub killprocesses {