The general problem this patch fixes is this: if you only dump a filesystem
once "dump -W" reports it as ready, you will have to run "dump -W" one day
and one second since the last time it was dumped.

My fix reduces the precision of old dump dates used for comparison to
minutes, rather than seconds (for example, if your cron backup script ran
dump on this filesystem at 01:30:12 yesterday, but got to dump -W at 01:30:09
today, that should be "good enough").  It also changes the comparison of
time_t times from "<" to "<=", so that if the dump ran at 01:30:00 yesterday,
dump -W will report it as ready to be dumped again today at 01:30:00.  (All
assuming that /etc/fstab reports that the filesystem should be backed up
daily).

It should be fairly safe.  The only other time makedumpdate() (the first
change) is called is when writing out /etc/dumpdates, so it will have the
side effect of erasing the seconds value stored in /etc/dumpdates.  On
the other hand, this means that the precision stored in /etc/dumpdates is
more in line with the precision the user is presented with, and the precision
they have control over with cron.

An alternative would be to convert the time_t to a tm struct, strip the
seconds, and convert back to time_t in lastdump().

Index: itime.c
===================================================================
RCS file: /cvs/src/sbin/dump/itime.c,v
retrieving revision 1.17
diff -u itime.c
--- itime.c     27 Oct 2009 23:59:32 -0000      1.17
+++ itime.c     29 Dec 2011 21:54:42 -0000
@@ -249,6 +249,7 @@
                return(-1);
        str = strptime(un_buf, "%a %b %e %H:%M:%S %Y", &then);
        then.tm_isdst = -1;
+       then.tm_sec = 0;
        if (str == NULL || (*str != '\n' && *str != '\0'))
                ddp->dd_ddate = (time_t) -1;
        else
Index: optr.c
===================================================================
RCS file: /cvs/src/sbin/dump/optr.c,v
retrieving revision 1.31
diff -u optr.c
--- optr.c      27 Oct 2009 23:59:32 -0000      1.31
+++ optr.c      29 Dec 2011 21:54:42 -0000
@@ -390,7 +390,7 @@
                dt = fstabsearch(dtwalk->dd_name);
                dumpme = (dt != NULL &&
                    dt->fs_freq != 0 &&
-                   dtwalk->dd_ddate < tnow - (dt->fs_freq * SECSPERDAY));
+                   dtwalk->dd_ddate <= tnow - (dt->fs_freq * SECSPERDAY));
                if (arg != 'w' || dumpme)
                        (void) printf(
                            "%c %8s\t(%6s) Last dump: Level %c, Date %s\n",
-- 
 Matthew Weigel
 hacker
 unique & idempot . ent

Reply via email to