]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/filed/job.c
ebl Modify disk-changer to check if slot contains something before
[bacula/bacula] / bacula / src / filed / job.c
index 106bff14a8c0cc9cfc4443c9d60e0f884a229a6a..6c45c3bb9ad488f1881712b04c190f14b9526d65 100644 (file)
@@ -49,6 +49,7 @@ extern CLIENT *me;                    /* our client resource */
 /* Imported functions */
 extern int status_cmd(JCR *jcr);
 extern int qstatus_cmd(JCR *jcr);
+extern int accurate_cmd(JCR *jcr);
 
 /* Forward referenced functions */
 static int backup_cmd(JCR *jcr);
@@ -106,6 +107,7 @@ static struct s_cmds cmds[] = {
    {"RunBeforeJob", runbefore_cmd, 0},
    {"RunAfterJob",  runafter_cmd,  0},
    {"Run",          runscript_cmd, 0},
+   {"accurate",     accurate_cmd, 0},
    {NULL,       NULL}                  /* list terminator */
 };
 
@@ -303,6 +305,12 @@ void *handle_client_request(void *dirp)
             for (k=0; k<fo->regex.size(); k++) {
                regfree((regex_t *)fo->regex.get(k));
             }
+            for (k=0; k<fo->regexdir.size(); k++) {
+               regfree((regex_t *)fo->regexdir.get(k));
+            }
+            for (k=0; k<fo->regexfile.size(); k++) {
+               regfree((regex_t *)fo->regexfile.get(k));
+            }
             fo->regex.destroy();
             fo->regexdir.destroy();
             fo->regexfile.destroy();
@@ -313,11 +321,8 @@ void *handle_client_request(void *dirp)
             fo->base.destroy();
             fo->fstype.destroy();
             fo->drivetype.destroy();
-            if (fo->reader) {
-               free(fo->reader);
-            }
-            if (fo->writer) {
-               free(fo->writer);
+            if (fo->ignoredir != NULL) {
+               free(fo->ignoredir);
             }
          }
          incexe->opts_list.destroy();
@@ -465,6 +470,8 @@ static int job_cmd(JCR *jcr)
    jcr->sd_auth_key = bstrdup(sd_auth_key);
    free_pool_memory(sd_auth_key);
    Dmsg2(120, "JobId=%d Auth=%s\n", jcr->JobId, jcr->sd_auth_key);
+   Mmsg(jcr->errmsg, "JobId=%d Job=%s", jcr->JobId, jcr->Job);
+   generate_plugin_event(jcr, bEventJobStart, (void *)jcr->errmsg);
    return dir->fsend(OKjob, VERSION, LSMDATE, HOST_OS, DISTNAME, DISTVER);
 }
 
@@ -676,7 +683,7 @@ static void add_file_to_fileset(JCR *jcr, const char *fname, findFILESET *filese
       }
       break;
    case '<':
-      Dmsg0(100, "Doing < include on client.\n");
+      Dmsg1(100, "Doing < of '%s' include on client.\n", p + 1);
       p++;                      /* skip over < */
       if ((ffd = fopen(p, "rb")) == NULL) {
          berrno be;
@@ -842,14 +849,19 @@ static void add_fileset(JCR *jcr, const char *item)
       set_options(current_opts, item);
       state = state_options;
       break;
+   case 'Z':
+      current_opts = start_options(ff);
+      current_opts->ignoredir = bstrdup(item);
+      state = state_options;
+      break;
    case 'D':
       current_opts = start_options(ff);
-      current_opts->reader = bstrdup(item);
+//    current_opts->reader = bstrdup(item);
       state = state_options;
       break;
    case 'T':
       current_opts = start_options(ff);
-      current_opts->writer = bstrdup(item);
+//    current_opts->writer = bstrdup(item);
       state = state_options;
       break;
    default:
@@ -903,11 +915,8 @@ static bool term_fileset(JCR *jcr)
          for (k=0; k<fo->drivetype.size(); k++) {
             Dmsg1(400, "XD %s\n", (char *)fo->drivetype.get(k));
          }
-         if (fo->reader) {
-            Dmsg1(400, "D %s\n", fo->reader);
-         }
-         if (fo->writer) {
-            Dmsg1(400, "T %s\n", fo->writer);
+         if (fo->ignoredir) {
+            Dmsg1(400, "Z %s\n", fo->ignoredir);
          }
       }
       dlistString *node;
@@ -1067,6 +1076,16 @@ static void set_options(findFOPTS *fo, const char *opts)
          }
          fo->VerifyOpts[j] = 0;
          break;
+      case 'C':                  /* accurate options */
+         /* Copy Accurate Options */
+         for (j=0; *p && *p != ':'; p++) {
+            fo->AccurateOpts[j] = *p;
+            if (j < (int)sizeof(fo->AccurateOpts) - 1) {
+               j++;
+            }
+         }
+         fo->AccurateOpts[j] = 0;
+         break;
       case 'P':                  /* strip path */
          /* Get integer */
          p++;                    /* skip P */
@@ -1097,6 +1116,9 @@ static void set_options(findFOPTS *fo, const char *opts)
       case 'c':
          fo->flags |= FO_CHKCHANGES;
          break;
+      case 'N':
+         fo->flags |= FO_HONOR_NODUMP;
+         break;
       default:
          Emsg1(M_ERROR, 0, _("Unknown include/exclude option: %c\n"), *p);
          break;
@@ -1130,7 +1152,7 @@ static int fileset_cmd(JCR *jcr)
    if (!term_fileset(jcr)) {
       return 0;
    }
-   return bnet_fsend(dir, OKinc);
+   return dir->fsend(OKinc);
 }
 
 static void free_bootstrap(JCR *jcr)
@@ -1205,6 +1227,9 @@ static int level_cmd(JCR *jcr)
 
    level = get_memory(dir->msglen+1);
    Dmsg1(110, "level_cmd: %s", dir->msg);
+   if (strstr(dir->msg, "accurate")) {
+      jcr->accurate = true;
+   }
    if (sscanf(dir->msg, "level = %s ", level) != 1) {
       goto bail_out;
    }
@@ -1214,14 +1239,14 @@ static int level_cmd(JCR *jcr)
    /* Full backup requested? */
    } else if (strcmp(level, "full") == 0) {
       jcr->JobLevel = L_FULL;
-   } else if (strcmp(level, "differential") == 0) {
+   } else if (strstr(level, "differential")) {
       jcr->JobLevel = L_DIFFERENTIAL;
       free_memory(level);
       return 1;
-   } else if (strcmp(level, "incremental") == 0) {
+   } else if (strstr(level, "incremental")) {
       jcr->JobLevel = L_INCREMENTAL;
       free_memory(level);
-      return 1;   
+      return 1;
    /*
     * We get his UTC since time, then sync the clocks and correct it
     *   to agree with our clock.
@@ -1283,6 +1308,7 @@ static int level_cmd(JCR *jcr)
       Dmsg2(100, "adj = %d since_time=%d\n", (int)adj, (int)since_time);
       jcr->incremental = 1;           /* set incremental or decremental backup */
       jcr->mtime = (time_t)since_time; /* set since time */
+      generate_plugin_event(jcr, bEventSince, (void *)jcr->mtime);
    } else {
       Jmsg1(jcr, M_FATAL, 0, _("Unknown backup level: %s\n"), level);
       free_memory(level);
@@ -1292,6 +1318,7 @@ static int level_cmd(JCR *jcr)
    if (buf) {
       free_memory(buf);
    }
+   generate_plugin_event(jcr, bEventLevel, (void *)jcr->JobLevel);
    return dir->fsend(OKlevel);
 
 bail_out:
@@ -1437,10 +1464,10 @@ static int backup_cmd(JCR *jcr)
    }
    
    generate_daemon_event(jcr, "JobStart");
-   generate_plugin_event(jcr, bEventJobStart);
+   generate_plugin_event(jcr, bEventStartBackupJob);
 
 #if defined(WIN32_VSS)
-   /* START VSS ON WIN 32 */
+   /* START VSS ON WIN32 */
    if (jcr->VSS) {      
       if (g_pVSSClient->InitializeForBackup()) {   
         /* tell vss which drives to snapshot */   
@@ -1473,6 +1500,7 @@ static int backup_cmd(JCR *jcr)
          berrno be;
          Jmsg(jcr, M_WARNING, 0, _("VSS was not initialized properly. VSS support is disabled. ERR=%s\n"), be.bstrerror());
       } 
+      run_scripts(jcr, jcr->RunScripts, "ClientAfterVSS");
    }
 #endif
 
@@ -1532,7 +1560,7 @@ static int backup_cmd(JCR *jcr)
 
 cleanup:
 #if defined(WIN32_VSS)
-   /* STOP VSS ON WIN 32 */
+   /* STOP VSS ON WIN32 */
    /* tell vss to close the backup session */
    if (jcr->VSS) {
       if (g_pVSSClient->CloseBackup()) {             
@@ -1550,6 +1578,7 @@ cleanup:
    }
 #endif
 
+   generate_plugin_event(jcr, bEventEndBackupJob);
    return 0;                          /* return and stop command loop */
 }
 
@@ -1587,7 +1616,8 @@ static int verify_cmd(JCR *jcr)
    dir->fsend(OKverify);
 
    generate_daemon_event(jcr, "JobStart");
-   generate_plugin_event(jcr, bEventJobStart);
+   generate_plugin_event(jcr, bEventLevel, (void *)jcr->JobLevel);
+   generate_plugin_event(jcr, bEventStartVerifyJob);
 
    Dmsg1(110, "bfiled>dird: %s", dir->msg);
 
@@ -1625,7 +1655,7 @@ static int verify_cmd(JCR *jcr)
    }
 
    dir->signal(BNET_EOD);
-
+   generate_plugin_event(jcr, bEventEndVerifyJob);
    return 0;                          /* return and terminate command loop */
 }
 
@@ -1703,7 +1733,7 @@ static int restore_cmd(JCR *jcr)
     */
    start_dir_heartbeat(jcr);
    generate_daemon_event(jcr, "JobStart");
-   generate_plugin_event(jcr, bEventJobStart);
+   generate_plugin_event(jcr, bEventStartRestoreJob);
    do_restore(jcr);
    stop_dir_heartbeat(jcr);
 
@@ -1730,6 +1760,7 @@ bail_out:
    }
 
    Dmsg0(130, "Done in job.c\n");
+   generate_plugin_event(jcr, bEventEndRestoreJob);
    return 0;                          /* return and terminate command loop */
 }
 
@@ -1802,6 +1833,9 @@ static void filed_free_jcr(JCR *jcr)
    free_runscripts(jcr->RunScripts);
    delete jcr->RunScripts;
 
+   if (jcr->JobId != 0)
+      write_state_file(me->working_directory, "bacula-fd", get_first_port_host_order(me->FDaddrs));
+
    return;
 }