From: Kern Sibbald Date: Fri, 14 Dec 2007 16:01:25 +0000 (+0000) Subject: Apply patch from Bastian Friedrich X-Git-Tag: Release-3.0.0~2143 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=2278f0918fc2b2e78c298dbafd0158c49d390104;p=bacula%2Fbacula Apply patch from Bastian Friedrich that implement %f in RunScripts to pass the FileSet name. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@6065 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/AUTHORS b/bacula/AUTHORS index faa7ed37cb..6a013edcd6 100644 --- a/bacula/AUTHORS +++ b/bacula/AUTHORS @@ -21,6 +21,7 @@ Arno Lehmann Attila Fülöp Bernd Frick Bill Moran +Bastian Friedrich Carlos A. Molina G Carsten Paeth Chris Lee diff --git a/bacula/kernstodo b/bacula/kernstodo index a6703ff2d6..c2ca15ec94 100644 --- a/bacula/kernstodo +++ b/bacula/kernstodo @@ -1,5 +1,5 @@ Kern's ToDo List - 16 July 2007 + 14 December 2007 Document: @@ -71,8 +71,12 @@ Professional Needs: and http://www.openeyet.nl/scc/ for managing customer changes Priority: -- Plugins +- Complete Catalog in Pool +- Implement Bacula plugins -- design API - Scripts +- Prune by Job +- Prune by Job Level +- True automatic pruning - Duplicate Jobs Run, Fail, Skip, Higher, Promote, CancelLowerLevel Proximity @@ -86,14 +90,6 @@ Priority: 02-Nov 12:58 rufus-sd JobId 10: Wrote label to prelabeled Volume "Vol001" on device "DDS-4" (/dev/nst0) 02-Nov 12:58 rufus-sd JobId 10: Alert: TapeAlert[7]: Media Life: The tape has reached the end of its useful life. 02-Nov 12:58 rufus-dir JobId 10: Bacula rufus-dir 2.3.6 (26Oct07): 02-Nov-2007 12:58:51 -- Encrypt sd_auth_key = s with director's key = d - k[i] = s[i] + (d[i] & 0xF)) & 0xFF + 'A' skip - - Decrypt key = k with director's key - x = k[i] - (d[i] & 0xF)) - if (x < 0) { - x = k[i] - (d[i] & 0xF) + 16 - } - s[i] = x + 'A'; - Eliminate: /var is a different filesystem. Will not descend from / into /var - Separate Files and Directories in catalog - Create FileVersions table @@ -106,12 +102,7 @@ Priority: generation of the error message doesn't differentiate result==NULL and a bad status from that result. Not only that, the result is cleared on a bail_out without having generated the error message. -- Erabt if min_block_size > max_block_size - KIWI -- Implement wait on multiple objects - - Multiple max times - - pthread signal - - socket input ready - Implement SDErrors (must return from SD) - Implement USB keyboard support in rescue CD. - Implement continue spooling while despooling. @@ -1350,7 +1341,6 @@ Documentation to do: (any release a little bit at a time) - Have SD compute MD5 or SHA1 and compare to what FD computes. - Make VolumeToCatalog calculate an MD5 or SHA1 from the actual data on the Volume and compare it. -- Implement Bacula plugins -- design API - Make bcopy read through bad tape records. - Program files (i.e. execute a program to read/write files). Pass read date of last backup, size of file last time. @@ -1576,6 +1566,10 @@ Jerry Schieffer ============================== Longer term to do: +- Implement wait on multiple objects + - Multiple max times + - pthread signal + - socket input ready - Design at hierarchial storage for Bacula. Migration and Clone. - Implement FSM (File System Modules). - Audit M_ error codes to ensure they are correct and consistent. @@ -1590,9 +1584,6 @@ Longer term to do: - Enhance time/duration input to allow multiple qualifiers e.g. 3d2h - Add ability to backup to two Storage devices (two SD sessions) at the same time -- e.g. onsite, offsite. -- Add the ability to consolidate old backup sets (basically do a restore - to tape and appropriately update the catalog). Compress Volume sets. - Might need to spool via file is only one drive is available. - Compress or consolidate Volumes of old possibly deleted files. Perhaps someway to do so with every volume that has less than x% valid files. @@ -1832,3 +1823,7 @@ Block Position: 0 does the right thing. - FD-SD quick disconnect - Building the in memory restore tree is slow. +- Erabt if min_block_size > max_block_size +- Add the ability to consolidate old backup sets (basically do a restore + to tape and appropriately update the catalog). Compress Volume sets. + Might need to spool via file is only one drive is available. diff --git a/bacula/src/dird/dird_conf.c b/bacula/src/dird/dird_conf.c index eebb9601a8..7a8036f3f3 100644 --- a/bacula/src/dird/dird_conf.c +++ b/bacula/src/dird/dird_conf.c @@ -1312,6 +1312,7 @@ void save_resource(int type, RES_ITEM *items, int pass) res->res_pool.NextPool = res_all.res_pool.NextPool; res->res_pool.RecyclePool = res_all.res_pool.RecyclePool; res->res_pool.storage = res_all.res_pool.storage; + res->res_pool.Catalog = res_all.res_pool.Catalog; break; case R_CONSOLE: if ((res = (URES *)GetResWithName(R_CONSOLE, res_all.res_con.hdr.name)) == NULL) { @@ -1742,6 +1743,7 @@ static void store_short_runscript(LEX *lc, RES_ITEM *item, int index, int pass) if (pass == 2) { RUNSCRIPT *script = new_runscript(); + script->set_job_code_callback(job_code_callback_filesetname); script->set_command(lc->str); @@ -1882,6 +1884,7 @@ static void store_runscript(LEX *lc, RES_ITEM *item, int index, int pass) RUNSCRIPT *script = new_runscript(); memcpy(script, &res_runscript, sizeof(RUNSCRIPT)); + script->set_job_code_callback(job_code_callback_filesetname); if (*runscripts == NULL) { *runscripts = New(alist(10, not_owned_by_alist)); @@ -1894,3 +1897,13 @@ static void store_runscript(LEX *lc, RES_ITEM *item, int index, int pass) scan_to_eol(lc); set_bit(index, res_all.hdr.item_present); } + +/* callback function for edit_job_codes */ +char *job_code_callback_filesetname(JCR *jcr, const char* param) { + if (param[0] == 'f') { + return jcr->fileset->name(); + } else { + return NULL; + } +} + diff --git a/bacula/src/dird/protos.h b/bacula/src/dird/protos.h index 30e627448d..482ee7f870 100644 --- a/bacula/src/dird/protos.h +++ b/bacula/src/dird/protos.h @@ -75,6 +75,7 @@ extern void catalog_update(JCR *jcr, BSOCK *bs); /* dird_conf.c */ extern const char *level_to_str(int level); +extern char *job_code_callback_filesetname(JCR *jcr, const char*); /* expand.c */ int variable_expansion(JCR *jcr, char *inp, POOLMEM **exp); diff --git a/bacula/src/lib/protos.h b/bacula/src/lib/protos.h index 93f1a20a7d..161ba6ee24 100644 --- a/bacula/src/lib/protos.h +++ b/bacula/src/lib/protos.h @@ -300,6 +300,9 @@ bool get_tls_enable (TLS_CONTEXT *ctx); /* util.c */ + +typedef char *(*job_code_callback_t)(JCR *, const char *); + bool is_buf_zero (char *buf, int len); void lcase (char *str); void bash_spaces (char *str); @@ -318,7 +321,7 @@ const char * job_level_to_str (int level); void make_session_key (char *key, char *seed, int mode); void encode_session_key (char *encode, char *session, char *key, int maxlen); void decode_session_key (char *decode, char *session, char *key, int maxlen); -POOLMEM * edit_job_codes (JCR *jcr, char *omsg, char *imsg, const char *to); +POOLMEM * edit_job_codes (JCR *jcr, char *omsg, char *imsg, const char *to, job_code_callback_t job_code_callback = NULL); void set_working_directory (char *wd); const char * last_path_separator (const char *str); diff --git a/bacula/src/lib/runscript.c b/bacula/src/lib/runscript.c index c36115c359..0b9db7848d 100644 --- a/bacula/src/lib/runscript.c +++ b/bacula/src/lib/runscript.c @@ -66,6 +66,7 @@ void RUNSCRIPT::reset_default(bool free_strings) fail_on_error = true; when = SCRIPT_Never; old_proto = false; /* TODO: drop this with bacula 1.42 */ + job_code_callback = NULL; } RUNSCRIPT *copy_runscript(RUNSCRIPT *src) @@ -207,7 +208,7 @@ bool RUNSCRIPT::run(JCR *jcr, const char *name) BPIPE *bpipe; char line[MAXSTRING]; - ecmd = edit_job_codes(jcr, ecmd, this->command, ""); + ecmd = edit_job_codes(jcr, ecmd, this->command, "", this->job_code_callback); Dmsg1(100, "runscript: running '%s'...\n", ecmd); Jmsg(jcr, M_INFO, 0, _("%s: run command \"%s\"\n"), name, ecmd); @@ -266,3 +267,9 @@ void RUNSCRIPT::debug() Dmsg1(200, _(" --> FailJobOnError=%u\n"), fail_on_error); Dmsg1(200, _(" --> RunWhen=%u\n"), when); } + +void RUNSCRIPT::set_job_code_callback(job_code_callback_t arg_job_code_callback) + +{ + this->job_code_callback = arg_job_code_callback; +} diff --git a/bacula/src/lib/runscript.h b/bacula/src/lib/runscript.h index 12710f5612..27b678b7cc 100644 --- a/bacula/src/lib/runscript.h +++ b/bacula/src/lib/runscript.h @@ -73,6 +73,8 @@ public: bool fail_on_error; /* abort job on error (Before) */ /* TODO : drop this with bacula 1.42 */ bool old_proto; /* used by old 1.3X protocol */ + job_code_callback_t job_code_callback; + /* Optional callback function passed to edit_job_code */ bool run(JCR *job, const char *name=""); /* name must contain "Before" or "After" keyword */ bool can_run_at_level(int JobLevel) { return true;}; /* TODO */ @@ -81,6 +83,8 @@ public: void reset_default(bool free_string = false); bool is_local(); /* true if running on local host */ void debug(); + + void set_job_code_callback(job_code_callback_t job_code_callback); }; /* create new RUNSCRIPT (set all value to 0) */ diff --git a/bacula/src/lib/util.c b/bacula/src/lib/util.c index 74cbfe6e75..1a15ecf6f1 100644 --- a/bacula/src/lib/util.c +++ b/bacula/src/lib/util.c @@ -609,7 +609,7 @@ void decode_session_key(char *decode, char *session, char *key, int maxlen) * to = recepients list * */ -POOLMEM *edit_job_codes(JCR *jcr, char *omsg, char *imsg, const char *to) +POOLMEM *edit_job_codes(JCR *jcr, char *omsg, char *imsg, const char *to, job_code_callback_t callback) { char *p, *q; const char *str; @@ -707,10 +707,17 @@ POOLMEM *edit_job_codes(JCR *jcr, char *omsg, char *imsg, const char *to) } break; default: - add[0] = '%'; - add[1] = *p; - add[2] = 0; - str = add; + str = NULL; + if (callback != NULL) { + str = callback(jcr, p); + } + + if (!str) { + add[0] = '%'; + add[1] = *p; + add[2] = 0; + str = add; + } break; } } else { diff --git a/bacula/technotes-2.3 b/bacula/technotes-2.3 index 1c23e168ab..de4d9708af 100644 --- a/bacula/technotes-2.3 +++ b/bacula/technotes-2.3 @@ -2,6 +2,8 @@ General: 14Dec07 +kes Apply patch from Bastian Friedrich + that implement %f in RunScripts to pass the FileSet name. kes Skip leading | when lex input comes from a pipe as suggested by Michael Stapelberg . 13Dec07