]> git.sur5r.net Git - bacula/bacula/commitdiff
take ideas from previous try
authorEric Bollengier <eric@eb.homelinux.org>
Wed, 29 Jul 2009 13:43:21 +0000 (15:43 +0200)
committerEric Bollengier <eric@eb.homelinux.org>
Mon, 3 Aug 2009 14:39:17 +0000 (16:39 +0200)
bacula/src/dird/dird_conf.c
bacula/src/dird/dird_conf.h
bacula/src/filed/accurate.c
bacula/src/filed/job.c

index 7a3f44603030a7a8987b19a32fba28f4b69a0f12..2daba3b6873619d634b28a413042a726d1f88e93 100644 (file)
@@ -338,6 +338,7 @@ RES_ITEM job_items[] = {
    {"cancelqueuedduplicates",  store_bool, ITEM(res_job.CancelQueuedDuplicates), 0, ITEM_DEFAULT, false},
    {"cancelrunningduplicates", store_bool, ITEM(res_job.CancelRunningDuplicates), 0, ITEM_DEFAULT, false},
    {"pluginoptions", store_str, ITEM(res_job.PluginOptions), 0, 0, 0},
+   {"base", store_alist_res, ITEM(res_job.base),  R_JOB, 0, 0},
    {NULL, NULL, {0}, 0, 0, 0}
 };
 
@@ -700,6 +701,12 @@ void dump_resource(int type, RES *reshdr, void sendit(void *sock, const char *fm
             dump_resource(-R_STORAGE, (RES *)store, sendit, sock);
          }
       }
+      if (res->res_job.base) {
+         JOB *job;
+         foreach_alist(job, res->res_job.base) {
+            sendit(sock, _("  --> Base %s\n"), job->name());
+         }
+      }
       if (res->res_job.RunScripts) {
         RUNSCRIPT *script;
         foreach_alist(script, res->res_job.RunScripts) {
@@ -1294,6 +1301,9 @@ void free_resource(RES *sres, int type)
       if (res->res_job.storage) {
          delete res->res_job.storage;
       }
+      if (res->res_job.base) {
+         delete res->res_job.base;
+      }
       if (res->res_job.RunScripts) {
          free_runscripts(res->res_job.RunScripts);
          delete res->res_job.RunScripts;
@@ -1429,6 +1439,7 @@ void save_resource(int type, RES_ITEM *items, int pass)
          res->res_job.client     = res_all.res_job.client;
          res->res_job.fileset    = res_all.res_job.fileset;
          res->res_job.storage    = res_all.res_job.storage;
+         res->res_job.base       = res_all.res_job.base;
          res->res_job.pool       = res_all.res_job.pool;
          res->res_job.full_pool  = res_all.res_job.full_pool;
          res->res_job.inc_pool   = res_all.res_job.inc_pool;
index 231dfabe5d6ab084ed7ae04d1863cb87b48de1ac..297f408e920ada434c8919aa42aee9d8d061978b 100644 (file)
@@ -436,7 +436,7 @@ public:
    bool AllowHigherDuplicates;        /* Permit Higher Level */
    bool CancelQueuedDuplicates;       /* Cancel queued jobs */
    bool CancelRunningDuplicates;      /* Cancel Running jobs */
-   
+   alist *base;                       /* Base jobs */   
 
    /* Methods */
    char *name() const;
index 4d050b5df01ab1f836b78c220b303564f87eb48d..49d78ffb86791601e29bae552d17783de38935a0 100644 (file)
@@ -38,7 +38,7 @@ static int dbglvl=200;
 typedef struct PrivateCurFile {
    hlink link;
    char *fname;
-   utime_t ctime;
+   utime_t ctime;               /* can be replaced by struct stat */
    utime_t mtime;
    bool seen;
 } CurFile;
@@ -102,7 +102,7 @@ bool accurate_send_deleted_list(JCR *jcr)
    FF_PKT *ff_pkt;
    int stream = STREAM_UNIX_ATTRIBUTES;
 
-   if (!jcr->accurate || jcr->get_JobLevel() == L_FULL) {
+   if (!jcr->accurate) {
       goto bail_out;
    }
 
@@ -179,7 +179,7 @@ bool accurate_check_file(JCR *jcr, FF_PKT *ff_pkt)
    char *fname;
    CurFile elt;
 
-   if (!jcr->accurate || jcr->get_JobLevel() == L_FULL) {
+   if (!jcr->accurate) {
       return true;
    }
 
@@ -202,6 +202,108 @@ bool accurate_check_file(JCR *jcr, FF_PKT *ff_pkt)
       goto bail_out;
    }
 
+#if 0
+   /*
+    * Loop over options supplied by user and verify the
+    * fields he requests.
+    */
+   for (p=Opts_Digest; *p; p++) {
+      char ed1[30], ed2[30];
+      switch (*p) {
+      case 'i':                /* compare INODEs */
+         if (statc.st_ino != statf.st_ino) {
+            prt_fname(jcr);
+            Jmsg(jcr, M_INFO, 0, _("      st_ino   differ. Cat: %s File: %s\n"),
+                 edit_uint64((uint64_t)statc.st_ino, ed1),
+                 edit_uint64((uint64_t)statf.st_ino, ed2));
+            set_jcr_job_status(jcr, JS_Differences);
+         }
+         break;
+      case 'p':                /* permissions bits */
+         if (statc.st_mode != statf.st_mode) {
+            prt_fname(jcr);
+            Jmsg(jcr, M_INFO, 0, _("      st_mode  differ. Cat: %x File: %x\n"),
+                 (uint32_t)statc.st_mode, (uint32_t)statf.st_mode);
+            set_jcr_job_status(jcr, JS_Differences);
+         }
+         break;
+      case 'n':                /* number of links */
+         if (statc.st_nlink != statf.st_nlink) {
+            prt_fname(jcr);
+            Jmsg(jcr, M_INFO, 0, _("      st_nlink differ. Cat: %d File: %d\n"),
+                 (uint32_t)statc.st_nlink, (uint32_t)statf.st_nlink);
+            set_jcr_job_status(jcr, JS_Differences);
+         }
+         break;
+      case 'u':                /* user id */
+         if (statc.st_uid != statf.st_uid) {
+            prt_fname(jcr);
+            Jmsg(jcr, M_INFO, 0, _("      st_uid   differ. Cat: %u File: %u\n"),
+                 (uint32_t)statc.st_uid, (uint32_t)statf.st_uid);
+            set_jcr_job_status(jcr, JS_Differences);
+         }
+         break;
+      case 'g':                /* group id */
+         if (statc.st_gid != statf.st_gid) {
+            prt_fname(jcr);
+            Jmsg(jcr, M_INFO, 0, _("      st_gid   differ. Cat: %u File: %u\n"),
+                 (uint32_t)statc.st_gid, (uint32_t)statf.st_gid);
+            set_jcr_job_status(jcr, JS_Differences);
+         }
+         break;
+      case 's':                /* size */
+         if (statc.st_size != statf.st_size) {
+            prt_fname(jcr);
+            Jmsg(jcr, M_INFO, 0, _("      st_size  differ. Cat: %s File: %s\n"),
+                 edit_uint64((uint64_t)statc.st_size, ed1),
+                 edit_uint64((uint64_t)statf.st_size, ed2));
+            set_jcr_job_status(jcr, JS_Differences);
+         }
+         break;
+      case 'a':                /* access time */
+         if (statc.st_atime != statf.st_atime) {
+            prt_fname(jcr);
+            Jmsg(jcr, M_INFO, 0, _("      st_atime differs\n"));
+            set_jcr_job_status(jcr, JS_Differences);
+         }
+         break;
+      case 'm':
+         if (statc.st_mtime != statf.st_mtime) {
+            prt_fname(jcr);
+            Jmsg(jcr, M_INFO, 0, _("      st_mtime differs\n"));
+            set_jcr_job_status(jcr, JS_Differences);
+         }
+         break;
+      case 'c':                /* ctime */
+         if (statc.st_ctime != statf.st_ctime) {
+            prt_fname(jcr);
+            Jmsg(jcr, M_INFO, 0, _("      st_ctime differs\n"));
+            set_jcr_job_status(jcr, JS_Differences);
+         }
+         break;
+      case 'd':                /* file size decrease */
+         if (statc.st_size > statf.st_size) {
+            prt_fname(jcr);
+            Jmsg(jcr, M_INFO, 0, _("      st_size  decrease. Cat: %s File: %s\n"),
+                 edit_uint64((uint64_t)statc.st_size, ed1),
+                 edit_uint64((uint64_t)statf.st_size, ed2));
+            set_jcr_job_status(jcr, JS_Differences);
+         }
+         break;
+      case '5':                /* compare MD5 */
+         Dmsg1(500, "set Do_MD5 for %s\n", jcr->fname);
+         do_Digest = CRYPTO_DIGEST_MD5;
+         break;
+      case '1':                 /* compare SHA1 */
+         do_Digest = CRYPTO_DIGEST_SHA1;
+               break;
+      case ':':
+      case 'V':
+      default:
+         break;
+            }
+   }
+#endif
    /*
     * We check only mtime/ctime like with the normal
     * incremental/differential mode
@@ -214,9 +316,8 @@ bool accurate_check_file(JCR *jcr, FF_PKT *ff_pkt)
    } else if (!(ff_pkt->flags & FO_MTIMEONLY) 
               && (elt.ctime != ff_pkt->statp.st_ctime)) {
 //   Jmsg(jcr, M_SAVED, 0, _("%s      st_ctime differs\n"), fname);
-      Dmsg3(dbglvl, "%s      st_ctime differs\n", 
-            fname, elt.ctime, ff_pkt->statp.st_ctime);
-     stat = true;
+      Dmsg1(dbglvl, "%s      st_ctime differs\n", fname);
+      stat = true;
    }
 
    accurate_mark_file_as_seen(jcr, &elt);
@@ -236,7 +337,7 @@ int accurate_cmd(JCR *jcr)
    int len;
    int32_t nb;
 
-   if (!jcr->accurate || job_canceled(jcr) || jcr->get_JobLevel()==L_FULL) {
+   if (job_canceled(jcr)) {
       return true;
    }
    if (sscanf(dir->msg, "accurate files=%ld", &nb) != 1) {
@@ -244,6 +345,8 @@ int accurate_cmd(JCR *jcr)
       return false;
    }
 
+   jcr->accurate = true;
+
    accurate_init(jcr, nb);
 
    /*
index af59139c5f43b4d1dfcfbc7fadc31ca4a32aa164..e41d7f270b73ce730874edf309d56cd11807c99c 100644 (file)
@@ -1256,6 +1256,8 @@ static int level_cmd(JCR *jcr)
 
    level = get_memory(dir->msglen+1);
    Dmsg1(100, "level_cmd: %s", dir->msg);
+
+   /* keep compatibility with older directors */
    if (strstr(dir->msg, "accurate")) {
       jcr->accurate = true;
    }