Fix verification when dump takes more than a day
authorJamie Cameron <jcameron@webmin.com>
Wed, 2 Jun 2010 19:57:20 +0000 (12:57 -0700)
committerJamie Cameron <jcameron@webmin.com>
Wed, 2 Jun 2010 19:57:20 +0000 (12:57 -0700)
fsdump/CHANGELOG
fsdump/backup.cgi
fsdump/backup.pl
fsdump/freebsd-lib.pl
fsdump/fsdump-lib.pl
fsdump/irix-lib.pl
fsdump/linux-lib.pl
fsdump/solaris-lib.pl

index e49e1a9..09fff5e 100644 (file)
@@ -40,3 +40,5 @@ Fixed a bug that prevented backups of directories with spaces in their names fro
 ---- Changes since 1.470 ----
 When terminating a running backup, all sub-processes such as tar and dump commands are killed too.
 Converted the UI on Solaris, OSX and FreeBSD to use the new Webmin UI library.
+---- Changes since 1.510 ----
+Fixed verification when a dump is to a date-based destination and takes more than one day.
index bcc6e78..f27d720 100755 (executable)
@@ -42,7 +42,8 @@ else {
                }
        else {
                # Do the dump
-               $ok = &execute_dump($dump, STDOUT, 1, 0);
+               $now = time();
+               $ok = &execute_dump($dump, STDOUT, 1, 0, $now);
                print "</pre>\n";
                if (!$bok) {
                        print "<b>$text{'backup_afterfailed'}</b><p>\n";
@@ -52,7 +53,7 @@ else {
                        if ($dump->{'reverify'}) {
                                print "<b>$text{'backup_reverify'}</b><p>\n";
                                print "<pre>";
-                               $ok = &verify_dump($dump, STDOUT, 1, 0);
+                               $ok = &verify_dump($dump, STDOUT, 1, 0, $now);
                                print "</pre>";
                                }
                        if ($ok) {
index 09f0497..418a264 100755 (executable)
@@ -48,14 +48,15 @@ else {
                }
        else {
                # Do the backup
-               $ok = &execute_dump($dump, OUT, 0, 1);
+               $now = time();
+               $ok = &execute_dump($dump, OUT, 0, 1, $now);
 
                # Re-update the status file
                if ($ok) {
                        # Worked .. but verify if asked
                        if ($dump->{'reverify'}) {
                                print OUT "\n$text{'email_verify'}\n";
-                               $ok = &verify_dump($dump, OUT, 0, 1);
+                               $ok = &verify_dump($dump, OUT, 0, 1, $now);
                                }
                        if ($ok) {
                                $status{'status'} = 'complete';
index b80de91..d32fa7e 100755 (executable)
@@ -166,7 +166,7 @@ else {
        }
 }
 
-# execute_dump(&dump, filehandle, escape)
+# execute_dump(&dump, filehandle, escape, background-mode, [time])
 # Executes a dump and displays the output
 sub execute_dump
 {
@@ -175,13 +175,13 @@ local ($cmd, $flags);
 
 if ($_[0]->{'huser'}) {
        $flags = "-f '$_[0]->{'huser'}\@$_[0]->{'host'}:".
-               &date_subs($_[0]->{'hfile'})."'";
+               &date_subs($_[0]->{'hfile'}, $_[4])."'";
        }
 elsif ($_[0]->{'host'}) {
-       $flags = "-f '$_[0]->{'host'}:".&date_subs($_[0]->{'hfile'})."'";
+       $flags = "-f '$_[0]->{'host'}:".&date_subs($_[0]->{'hfile'}, $_[4])."'";
        }
 else {
-       $flags = "-f '".&date_subs($_[0]->{'file'})."'";
+       $flags = "-f '".&date_subs($_[0]->{'file'}, $_[4])."'";
        }
 local $tapecmd = $_[0]->{'multi'} && $_[0]->{'fs'} eq 'tar' ? $multi_cmd :
                 $_[0]->{'multi'} ? undef :
index 27463c0..6ea4948 100755 (executable)
@@ -99,13 +99,13 @@ $fs2 = "ext2" if ($fs2 eq "ext3");
 return lc($fs1) eq lc($fs2);
 }
 
-# date_subs(string)
+# date_subs(string, [time])
 sub date_subs
 {
 if ($config{'date_subs'}) {
        eval "use POSIX";
        eval "use posix" if ($@);
-       local @tm = localtime(time());
+       local @tm = localtime($_[1] || time());
        &clear_time_locale();
        local $rv = strftime($_[0], @tm);
        &reset_time_locale();
index 5526e04..a86bf2b 100755 (executable)
@@ -111,7 +111,7 @@ $_[0]->{'overwrite'} = $in{'overwrite'};
 $_[0]->{'erase'} = $in{'erase'};
 }
 
-# execute_dump(&dump, filehandle, escape)
+# execute_dump(&dump, filehandle, escape, background-mode, [time])
 # Executes a dump and displays the output
 sub execute_dump
 {
@@ -119,13 +119,13 @@ local $fh = $_[1];
 local ($cmd, $flag);
 if ($_[0]->{'huser'}) {
        $flag = " -f '$_[0]->{'huser'}\@$_[0]->{'host'}:".
-               &date_subs($_[0]->{'hfile'})."'";
+               &date_subs($_[0]->{'hfile'}, $_[4])."'";
        }
 elsif ($_[0]->{'host'}) {
-       $flag = " -f '$_[0]->{'host'}:".&date_subs($_[0]->{'hfile'})."'";
+       $flag = " -f '$_[0]->{'host'}:".&date_subs($_[0]->{'hfile'}, $_[4])."'";
        }
 else {
-       $flag = " -f '".&date_subs($_[0]->{'file'})."'";
+       $flag = " -f '".&date_subs($_[0]->{'file'}, $_[4])."'";
        }
 $cmd = "xfsdump -l $_[0]->{'level'}";
 $cmd .= $flag;
index 435dcec..cf615c0 100755 (executable)
@@ -327,13 +327,13 @@ else {
 $_[0]->{'remount'} = $in{'remount'};
 }
 
-# execute_dump(&dump, filehandle, escape, background-mode)
+# execute_dump(&dump, filehandle, escape, background-mode, [time])
 # Executes a dump and displays the output
 sub execute_dump
 {
 local $fh = $_[1];
 local ($cmd);
-($flag, $hfile) = &dump_flag($_[0]);
+($flag, $hfile) = &dump_flag($_[0], $_[4]);
 local $tapecmd = $_[0]->{'multi'} && $_[0]->{'fs'} eq 'tar' ? $multi_cmd :
                 $_[0]->{'notape'} ? undef :
                 $_[0]->{'multi'} ? undef :
@@ -456,14 +456,14 @@ else {
 return ($flag, $hfile);
 }
 
-# verify_dump(&dump, filehandle, escape, background-mode)
+# verify_dump(&dump, filehandle, escape, background-mode, [time])
 # Verifies a dump, returning 1 if OK and 0 if not
 sub verify_dump
 {
 # Build verify command
 local $fh = $_[1];
 local $vcmd;
-local ($flag, $hfile) = &dump_flag($_[0]);
+local ($flag, $hfile) = &dump_flag($_[0], $_[4]);
 if ($_[0]->{'fs'} eq "tar") {
        $vcmd = "tar -t -v";
        $vcmd .= " -z" if ($_[0]->{'gzip'} == 1);
index 552a3ea..add45e7 100755 (executable)
@@ -81,7 +81,7 @@ $_[0]->{'level'} = $in{'level'};
 $_[0]->{'offline'} = $in{'offline'};
 }
 
-# execute_dump(&dump, filehandle, escape)
+# execute_dump(&dump, filehandle, escape, background-mode, [time])
 # Executes a dump and displays the output
 sub execute_dump
 {
@@ -92,13 +92,13 @@ $cmd .= "v" if ($_[0]->{'verify'});
 $cmd .= "o" if ($_[0]->{'offline'});
 if ($_[0]->{'huser'}) {
        $cmd .= "f '$_[0]->{'huser'}\@$_[0]->{'host'}:".
-               &date_subs($_[0]->{'hfile'})."'";
+               &date_subs($_[0]->{'hfile'}, $_[4])."'";
        }
 elsif ($_[0]->{'host'}) {
-       $cmd .= "f '$_[0]->{'host'}:".&date_subs($_[0]->{'hfile'})."'";
+       $cmd .= "f '$_[0]->{'host'}:".&date_subs($_[0]->{'hfile'}, $_[4])."'";
        }
 else {
-       $cmd .= "f '".&date_subs($_[0]->{'file'})."'";
+       $cmd .= "f '".&date_subs($_[0]->{'file'}, $_[4])."'";
        }
 $cmd .= " $_[0]->{'extra'}" if ($_[0]->{'extra'});
 local @dirs = $_[0]->{'tabs'} ? split(/\t+/, $_[0]->{'dir'})