]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/tools/bbatch.c
Make PurgeMigrationJob directive name correspond to doc
[bacula/bacula] / bacula / src / tools / bbatch.c
index 17d80e94fe657eb1a5f7d8eefd6bb8dfe83b9bb6..00244f0d6cfc7e1b900379a407641501fee69630 100644 (file)
@@ -15,7 +15,7 @@
    The main author of Bacula is Kern Sibbald, with contributions from
    many others, a complete list can be found in the file AUTHORS.
    This program is Free Software; you can redistribute it and/or
-   modify it under the terms of version two of the GNU General Public
+   modify it under the terms of version three of the GNU Affero General Public
    License as published by the Free Software Foundation and included
    in the file LICENSE.
 
@@ -24,7 +24,7 @@
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    General Public License for more details.
 
-   You should have received a copy of the GNU General Public License
+   You should have received a copy of the GNU Affero General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
@@ -56,6 +56,7 @@
 #include "stored/stored.h"
 #include "findlib/find.h"
 #include "cats/cats.h"
+#include "cats/sql_glue.h"
  
 /* Forward referenced functions */
 static void *do_batch(void *);
@@ -80,6 +81,8 @@ PROG_COPYRIGHT
 " will start 3 thread and load dat1, dat and datx in your catalog\n"
 "See bbatch.c to generate datafile\n\n"
 "Usage: bbatch [ options ] -w working/dir -f datafile\n"
+"       -b                with batch mode\n"
+"       -B                without batch mode\n"
 "       -d <nn>           set debug level to <nn>\n"
 "       -dt               print timestamp in debug output\n"
 "       -n <name>         specify the database name (default bacula)\n"
@@ -107,6 +110,7 @@ static int list_handler(void *ctx, int num_fields, char **row)
 int main (int argc, char *argv[])
 {
    int ch;
+   bool disable_batch = false;
    char *restore_list=NULL;
    setlocale(LC_ALL, "");
    bindtextdomain("bacula", LOCALEDIR);
@@ -121,12 +125,17 @@ int main (int argc, char *argv[])
 
    OSDependentInit();
 
-   while ((ch = getopt(argc, argv, "h:c:d:n:P:Su:vf:w:r:?")) != -1) {
+   while ((ch = getopt(argc, argv, "bBh:c:d:n:P:Su:vf:w:r:?")) != -1) {
       switch (ch) {
       case 'r':
          restore_list=bstrdup(optarg);
          break;
-
+      case 'B':
+         disable_batch = true;
+         break;
+      case 'b':
+         disable_batch = false;
+         break;
       case 'd':                    /* debug level */
          if (*optarg == 't') {
             dbg_timestamp = true;
@@ -187,8 +196,8 @@ int main (int argc, char *argv[])
       btime_t start, end;
       /* To use the -r option, the catalog should already contains records */
       
-      if ((db=db_init(NULL, NULL, db_name, db_user, db_password,
-                      db_host, 0, NULL, 0)) == NULL) {
+      if ((db = db_init_database(NULL, NULL, db_name, db_user, db_password,
+                                 db_host, 0, NULL, false, disable_batch)) == NULL) {
          Emsg0(M_ERROR_TERM, 0, _("Could not init Bacula database\n"));
       }
       if (!db_open_database(NULL, db)) {
@@ -196,7 +205,7 @@ int main (int argc, char *argv[])
       }
 
       start = get_current_btime();
-      db_get_file_list(NULL, db, restore_list, list_handler, &nb_file);
+      db_get_file_list(NULL, db, restore_list, false, false, list_handler, &nb_file);
       end = get_current_btime();
 
       Pmsg3(0, _("Computing file list for jobid=%s files=%lld secs=%d\n"), 
@@ -206,11 +215,12 @@ int main (int argc, char *argv[])
       return 0;
    }
 
-#ifdef HAVE_BATCH_FILE_INSERT
-   printf("With new Batch mode\n");
-#else
-   printf("Without new Batch mode\n");
-#endif
+   if (disable_batch) {
+      printf("Without new Batch mode\n");
+   } else {
+      printf("With new Batch mode\n");
+   }
+
    i = nb;
    while (--i >= 0) {
       pthread_t thid;
@@ -221,8 +231,8 @@ int main (int argc, char *argv[])
       bjcr->NumReadVolumes = 0;
       bjcr->NumWriteVolumes = 0;
       bjcr->JobId = getpid();
-      bjcr->set_JobType(JT_CONSOLE);
-      bjcr->set_JobLevel(L_FULL);
+      bjcr->setJobType(JT_CONSOLE);
+      bjcr->setJobLevel(L_FULL);
       bjcr->JobStatus = JS_Running;
       bjcr->where = bstrdup(files[i]);
       bjcr->job_name = get_pool_memory(PM_FNAME);
@@ -235,8 +245,8 @@ int main (int argc, char *argv[])
       bjcr->fileset_md5 = get_pool_memory(PM_FNAME);
       pm_strcpy(bjcr->fileset_md5, "Dummy.fileset.md5");
       
-      if ((db=db_init(NULL, NULL, db_name, db_user, db_password,
-                      db_host, 0, NULL, 0)) == NULL) {
+      if ((db = db_init_database(NULL, NULL, db_name, db_user, db_password,
+                                 db_host, 0, NULL, false, false)) == NULL) {
          Emsg0(M_ERROR_TERM, 0, _("Could not init Bacula database\n"));
       }
       if (!db_open_database(NULL, db)) {
@@ -311,7 +321,7 @@ static void *do_batch(void *jcr)
          printf("\r%i", lineno);
       }
       fill_attr(&ar, data);
-      if (!db_create_file_attributes_record(bjcr, bjcr->db, &ar)) {
+      if (!db_create_attributes_record(bjcr, bjcr->db, &ar)) {
          Emsg0(M_ERROR_TERM, 0, _("Error while inserting file\n"));
       }
    }