[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bacula-devel] Accept "spooldata" flag on bconsole "run" cmd


Hi,

currently, Bacula accepts a "Spool data" flag for storages within job 
ressources, and in Run statements in a schedule. Modifying the Spooling 
statement while calling "run" inside bconsole is not available.

Doing so is sensible in a number of cases; often, Full backups may be 
non-spooled, while incrementals should be spooled. Defining a Job as "to 
disk" per default, but enabling spooling when running the same job to tape, 
is quite sensible.

The attached patch
a) adds a "spooldata={yes|1|no|0}" to the run statement on the bconsole CLI
b) adds a "Spool data" "mod" option (number 9)
c) displays the current "Spooling: {yes|no}" in the display_job_parameters
   function

I am not the only person with such a request; quite a similar question was 
risen a few days ago on the user mailinglist.

Feel free to use as usual :)

Sorry: The patch was created against an SVN snapshot of 2008-10-14. I will be 
happy to re-create such a patch against current SVN if required. ua_run.c 
(which is the only file modified) has not been changed for some months now, 
though; the patch should apply cleanly.

Thx & Best regards
   Bastian

-- 
Collax GmbH . Burkheimer Straße 3 . 79111 Freiburg . Germany
p: +49 (0) 761-45684-28
f: +49 (0) 761-45684-10        www.collax.com

Geschäftsführer: William K. Hite / Boris Nalbach
AG München HRB 158898 . Ust.-IdNr: DE 814464942
\ There are 2 ways to handle women and I know neither.
--- bacula-2.5-20081014svn/src/dird/ua_run.c.ori	2008-07-17 22:53:01.000000000 +0200
+++ bacula-2.5-20081014svn/src/dird/ua_run.c	2008-11-04 14:30:04.000000000 +0100
@@ -60,6 +60,8 @@
    int files;
    bool cloned;
    bool mod;
+   bool spool_data;
+   bool spool_data_set;
 
    /* Methods */
    run_ctx() { memset(this, 0, sizeof(run_ctx)); 
@@ -174,6 +176,7 @@
 start_job:
       Dmsg3(100, "JobId=%u using pool %s priority=%d\n", (int)jcr->JobId, 
             jcr->pool->name(), jcr->JobPriority);
+      Dmsg1(900, "Running a job; its spool_data = %d\n", jcr->spool_data);
       JobId = run_job(jcr);
       Dmsg4(100, "JobId=%u NewJobId=%d using pool %s priority=%d\n", (int)jcr->JobId, 
             JobId, jcr->pool->name(), jcr->JobPriority);
@@ -219,8 +222,9 @@
           jcr->get_JobType() == JT_MIGRATE ||
           jcr->get_JobType() == JT_VERIFY) {
          add_prompt(ua, _("Pool"));          /* 7 */
+         add_prompt(ua, _("Spool Data"));     /* 8 */
          if (jcr->get_JobType() == JT_VERIFY) {
-            add_prompt(ua, _("Verify Job"));  /* 8 */
+            add_prompt(ua, _("Verify Job"));  /* 9 */
          }
       } else if (jcr->get_JobType() == JT_RESTORE) {
          add_prompt(ua, _("Bootstrap"));     /* 7 */
@@ -335,14 +339,16 @@
          }
          goto try_again;
       case 8:
-         /* Verify Job */
-         if (jcr->get_JobType() == JT_VERIFY) {
-            rc.verify_job = select_job_resource(ua);
-            if (rc.verify_job) {
-              jcr->verify_job = rc.verify_job;
-            }
-            goto try_again;
-         }
+         /* Spool Data flag */
+         if (jcr->get_JobType() == JT_BACKUP ||
+             jcr->get_JobType() == JT_COPY ||
+             jcr->get_JobType() == JT_MIGRATE) {      /* Spool data flag */
+	     if (!get_yesno(ua, _("Spool data (yes/no):"))) {
+	        goto try_again;
+	     }
+	     jcr->spool_data = ua->pint32_val;
+	     goto try_again;
+	 }
          /* Where */
          if (!get_cmd(ua, _("Please enter path prefix for restore (/ for none): "))) {
             break;
@@ -361,6 +367,14 @@
          jcr->where = bstrdup(ua->cmd);
          goto try_again;
       case 9: 
+         /* Verify Job */
+         if (jcr->get_JobType() == JT_VERIFY) {
+            rc.verify_job = select_job_resource(ua);
+            if (rc.verify_job) {
+              jcr->verify_job = rc.verify_job;
+            }
+            goto try_again;
+         }
          /* File relocation */
          select_where_regexp(ua, jcr);
          goto try_again;
@@ -775,6 +789,7 @@
                         "FileSet:  %s\n"
                         "Pool:     %s (From %s)\n"
                         "Storage:  %s (From %s)\n"
+			"Spooling: %s\n"
                         "When:     %s\n"
                         "Priority: %d\n"
                         "%s%s%s"),
@@ -785,6 +800,7 @@
                  jcr->fileset->name(),
                  NPRT(jcr->pool->name()), jcr->pool_source,
                  jcr->wstore?jcr->wstore->name():"*None*", jcr->wstore_source,
+		 (jcr->spool_data ? "Yes" : "No"),
                  bstrutime(dt, sizeof(dt), jcr->sched_time),
                  jcr->JobPriority,
                  jcr->plugin_options?"Plugin Options: ":"",
@@ -964,6 +980,7 @@
            NPRT(jcr->pool->name()), jcr->pool_source,
            jcr->rstore->name(), jcr->rstore_source,
            jcr->wstore?jcr->wstore->name():"*None*", jcr->wstore_source,
+	   (jcr->spool_data ? "Yes" : "No"),
            jcr->MigrateJobId==0?"*None*":edit_uint64(jcr->MigrateJobId, ec1),
            bstrutime(dt, sizeof(dt), jcr->sched_time),
            jcr->catalog->name(),
@@ -1008,6 +1025,7 @@
       "backupclient",                 /* 23 */
       "restoreclient",                /* 24 */
       "pluginoptions",                /* 25 */
+      "spooldata",                    /* 26 */
       NULL};
 
 #define YES_POS 14
@@ -1021,6 +1039,7 @@
    rc.fileset_name = NULL;
    rc.verify_job_name = NULL;
    rc.previous_job_name = NULL;
+   rc.spool_data_set = 0;
 
 
    for (i=1; i<ua->argc; i++) {
@@ -1225,6 +1244,27 @@
                }
                kw_ok = true;
                break;
+            case 26: /* spooldata */
+	       if (rc.spool_data_set) {
+                  ua->send_msg(_("Spool flag specified twice.\n"));
+                  return false;
+	       }
+	       if ((strncasecmp(ua->argv[i], "yes", strlen(ua->argv[i])) == 0) ||
+	           (strncasecmp(ua->argv[i], _("yes"), strlen(ua->argv[i])) == 0) ||
+	           (strncmp(ua->argv[i], "1", strlen(ua->argv[i])) == 0)) {
+	          rc.spool_data = 1;
+	          rc.spool_data_set = 1;
+		  kw_ok = true;
+	       } else if ((strncasecmp(ua->argv[i], "no", strlen(ua->argv[i])) == 0) ||
+	           (strncasecmp(ua->argv[i], _("no"), strlen(ua->argv[i])) == 0) ||
+	           (strncmp(ua->argv[i], "0", strlen(ua->argv[i])) == 0)) {
+	          rc.spool_data = 0;
+	          rc.spool_data_set = 1;
+		  kw_ok = true;
+               } else {
+                  ua->send_msg(_("Invalid spooldata flag.\n"));
+               }
+               break;
             default:
                break;
             }
@@ -1305,6 +1343,11 @@
    }
    Dmsg1(100, "Using pool %s\n", rc.pool->name());
 
+   if (rc.spool_data_set) {
+      rc.job->spool_data = rc.spool_data;
+   }
+   Dmsg1(900, "Spooling data: %s\n", (rc.job->spool_data ? "Yes" : "No"));
+
    if (rc.store_name) {
       rc.store->store = GetStoreResWithName(rc.store_name);
       pm_strcpy(rc.store->store_source, _("command line"));
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Bacula-devel mailing list
Bacula-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/bacula-devel


This mailing list archive is a service of Copilot Consulting.