From 74fe71b28aaee42049121aff3e86a7704a8f91b5 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Wed, 28 Apr 2004 13:11:02 +0000 Subject: [PATCH] Misc git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@1319 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/autoconf/aclocal.m4 | 4 + bacula/autoconf/config.h.in | 3 + bacula/autoconf/configure.in | 2 +- bacula/configure | 7 +- bacula/kernstodo | 138 ++++++++++------------------ bacula/scripts/mtx-changer.in | 4 +- bacula/src/baconfig.h | 11 +++ bacula/src/bacula.h | 2 +- bacula/src/dird/dird_conf.c | 30 ++++-- bacula/src/dird/fd_cmds.c | 10 +- bacula/src/dird/inc_conf.c | 74 +++++++++++++-- bacula/src/version.h | 4 +- bacula/src/win32/compat/winconfig.h | 4 +- 13 files changed, 179 insertions(+), 114 deletions(-) diff --git a/bacula/autoconf/aclocal.m4 b/bacula/autoconf/aclocal.m4 index 0ad0a8affb..f144d62190 100644 --- a/bacula/autoconf/aclocal.m4 +++ b/bacula/autoconf/aclocal.m4 @@ -568,6 +568,10 @@ AC_ARG_WITH(postgresql, POSTGRESQL_INCDIR=/usr/include/pgsql POSTGRESQL_LIBDIR=/usr/lib/pgsql POSTGRESQL_BINDIR=/usr/bin + elif test -f /usr/include/postgresql/libpq-fe.h; then + POSTGRESQL_INCDIR=/usr/include/postgresql + POSTGRESQL_LIBDIR=/usr/lib/postgresql + POSTGRESQL_BINDIR=/usr/bin else AC_MSG_RESULT(no) AC_MSG_ERROR(Unable to find libpq-fe.h in standard locations) diff --git a/bacula/autoconf/config.h.in b/bacula/autoconf/config.h.in index 58ddd8e8bf..db298b0084 100644 --- a/bacula/autoconf/config.h.in +++ b/bacula/autoconf/config.h.in @@ -338,6 +338,9 @@ /* Define to 1 if you have the header file, and it defines `DIR'. */ #undef HAVE_NDIR_H +/* Define to 1 if you have the `nl_langinfo' function. */ +#undef HAVE_NL_LANGINFO + /* Define to 1 if you have the `putenv' function. */ #undef HAVE_PUTENV diff --git a/bacula/autoconf/configure.in b/bacula/autoconf/configure.in index dde544c633..26e4aaa98f 100644 --- a/bacula/autoconf/configure.in +++ b/bacula/autoconf/configure.in @@ -454,7 +454,7 @@ AC_HEADER_STAT AC_HEADER_DIRENT AC_CHECK_FUNCS(strcasecmp select setenv putenv tcgetattr setlocale lstat lchown) -AC_CHECK_FUNCS(nanosleep) +AC_CHECK_FUNCS(nanosleep nl_langinfo) AC_CHECK_HEADERS(varargs.h) diff --git a/bacula/configure b/bacula/configure index 92517a105a..224466aa72 100755 --- a/bacula/configure +++ b/bacula/configure @@ -6352,7 +6352,8 @@ fi done -for ac_func in nanosleep + +for ac_func in nanosleep nl_langinfo do as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` echo "$as_me:$LINENO: checking for $ac_func" >&5 @@ -7187,6 +7188,10 @@ echo "$as_me: error: \"You can configure for only one database.\"" >&2;} POSTGRESQL_INCDIR=/usr/include/pgsql POSTGRESQL_LIBDIR=/usr/lib/pgsql POSTGRESQL_BINDIR=/usr/bin + elif test -f /usr/include/postgresql/libpq-fe.h; then + POSTGRESQL_INCDIR=/usr/include/postgresql + POSTGRESQL_LIBDIR=/usr/lib/postgresql + POSTGRESQL_BINDIR=/usr/bin else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 diff --git a/bacula/kernstodo b/bacula/kernstodo index 50c1a46713..c5b4b497be 100644 --- a/bacula/kernstodo +++ b/bacula/kernstodo @@ -43,6 +43,7 @@ For 1.33 Testing/Documentation: For version 1.35: +- Add check for tape alerts. - Add a "base" package to the window installer for pthreadsVCE.dll which is needed by all packages. - Add message to user to check for fixed block size when the forward @@ -698,37 +699,6 @@ Ideas from Jerry Scharf: > woorkstations to be shut down overnight to save power. > -- From Terry Manderson - jobdefs { # new structure - name = "monthlyUnixBoxen" - type = backup - level = full - schedule = monthly - storage = DLT - messages = Standard - pool = MonthlyPool - priority = 10 - } - - job { - name = "wakame" - jobdefs = "genericUnixSet" - client = wakame-fd - } - - job { - name = "durian" - jobdefs = "genericUnixSet" - client = durian-fd - } - - job { - name = "soy" - jobdefs = "UnixDevelBoxSet" - client = soy-fd - } - - - Autolabel should be specified by DIR instead of SD. - Storage daemon - Add media capacity @@ -877,56 +847,56 @@ Need: VolSessionId and VolSessionTime. ========================================================= - - ============================================================= - Request For Comments For File Backup Options - 10 November 2002 + File Backup Options Project + 28 April 2004 + Subject: File Backup Options Problem: - A few days ago, a Bacula user who is backing up to file volumes and - using compression asked if it was possible to suppress compressing - all .gz files since it was a waste of CPU time. Although Bacula - currently permits using different options (compression, ...) on - a directory by directory basis, it cannot do it on a file by - file basis, which is clearly what was desired. + Bacula users who are using compression would like to suppress + compressing all .gz files since it was a waste of CPU time. + Although Bacula currently permits using different options + (compression, ...) on a directory by directory basis, it cannot + do it on a file by file basis, which is clearly what was + desired. Proposed Implementation: To solve this problem, I propose the following: - Add a new Director resource type called Options. - - The Options resource will have records for all - options that can currently be specified on the Include record - (in a FileSet). Examples below. + - The Options resource will have records for all options that + can currently be specified on the Include record (in a + FileSet). Examples below. - The Options resource will permit an exclude option as well as a number of additional options. - - The heart of the Options resource is the ability to - supply any number of Match records which specify POSIX - regular expressions. These Match regular expressions are - applied to the fully qualified filename (path and all). If - one matches, then the Options will be used. + - The heart of the Options resource is the ability to supply + any number of Regex records which specify POSIX regular + expressions. These regular expressions are applied to the + fully qualified filename (path and all). If one matches, + then the Options will be used. - - When an Match specification matches an included file, the - options specified in the Options resource will override - the default options specified on the Include record. + - When a Regex specification matches an included file, the + options specified in the Options resource will override the + default options specified on the Include record. - Include records will be modified to permit referencing one or - more Options resources. The Options will be used - in the order listed on the Include record and the first - one that matches will be applied. + more Options resources. The Options will be used in the + order listed on the Include record and the first one that + matches will be applied. - Options (or specifications) currently supplied on the Include - record will be deprecated (i.e. removed in a later version a + record will be deprecated (i.e. removed in a later version a year or so from now). - The Exclude record will be deprecated as the same functionality - can be obtained by using an Exclude = yes in the Options. + can be obtained by using an Exclude = yes in the Options or + an Exclude = xxxx directive. Options records: The following records can appear in the Options resource. An @@ -944,12 +914,10 @@ Options records: - Recurse= (yes/no) - recurse into subdirectories - Sparse= (yes/no) - do sparse file backup - *Exclude= (yes/no) - exclude file from being saved + - *INclude= (yes/no) - include the file (needed??) - *Reader= (filename) - external read (backup) program - *Plugin= (filename) - read/write plugin module - - Include= (yes/no) - Include the file matched no additional - patterns are applied. - For Verify Jobs: - verify= (ipnougsamc5) - verify options @@ -960,14 +928,15 @@ Options records: Implementation: - Currently options specifying compression, MD5 signatures, recursion, - ... of a FileSet are supplied on the Include record. These will now - all be collected into a Options resource, which will be - specified in the Include in place of the options. Multiple Options - may be specified. Since the Options may contain regular expressions - that are applied to the full filename, this will give the ability - to specify backup options on a file by file basis to whatever level - of detail you wish. + Currently options specifying compression, MD5 signatures, + recursion, ... of a FileSet are supplied on the Include + record. These will now all be collected into a Options + resource, which will be specified in the Include in place of + the options. Multiple Options may be specified. Since the + Options may contain regular expressions that are applied to the + full filename, this will give the ability to specify backup + options on a file by file basis to whatever level of detail you + wish. Example: @@ -985,10 +954,12 @@ Example: FileSet { Name = "FullSet" Include { - Compression = GZIP; - Signature = MD5 - Wild = /*.?*/ # matches all files. - File = / + Options { + Compression = GZIP; + Signature = MD5 + Wild = /*.?*/ # matches all files. + } + Include = / } } @@ -997,8 +968,8 @@ Example: want to compress all files but not any file with extensions .gz or .Z. In that case, you will need to group two sets of options using the Options resource. Files may be anywhere except in an - option set??? All OptionSets apply to all files in the order - the OptionSets were specified. To have files included with + option set ??? All Options apply to all files in the order + the Options were specified. To have files included with different option sets without using wild-cards, use two or more Includes -- each one is handled in turn using only the files and optionsets specified in the include. @@ -1006,18 +977,18 @@ Example: FileSet { Name = "FullSet" Include { - OptionSet { + Options { Signature = MD5 # Note multiple Matches are ORed Wild = "*.gz" # matches .gz files Wild = "*.Z" # matches .Z files } - OptionSet { + Options { Compression = GZIP Signature = MD5 Wild = "*.?*" # matches all files } - File = / + Include = / } } @@ -1028,18 +999,6 @@ Example: compression. Questions: - - Is it necessary to provide some means of ANDing regular expressions - and negation? (not currently planned) - - e.g. Wild = /*.gz/ && !/big.gz/ - - - I see that Networker has a "null" module which, if specified, does not - backup the file, but does make an record of the file in the catalog - so that the catalog will reflect an exact picture of the filesystem. - The result is that the file can be "seen" when "browsing" the save - sets, but it cannot be restored. - - Is this really useful? Should it be implemented in Bacula? Results: After implementing the above, the user will be able to specify @@ -1049,6 +1008,7 @@ Results: ============================================= + ========================================================== Unsaved File design For each Incremental job that is run, there may be files that diff --git a/bacula/scripts/mtx-changer.in b/bacula/scripts/mtx-changer.in index 3e59e86907..17e57ec3ae 100644 --- a/bacula/scripts/mtx-changer.in +++ b/bacula/scripts/mtx-changer.in @@ -96,7 +96,7 @@ case $cmd in list) # echo "Requested list" - ${MTX} -f $ctl status | grep " *Storage Element [0-9]*:.*Full" | awk "{print \$slot \$device}" | sed "s/Full *\(:VolumeTag=\)*//" + ${MTX} -f $ctl status | grep " *Storage Element [0-9]*:.*Full" | awk "{print \$3 \$4}" | sed "s/Full *\(:VolumeTag=\)*//" ;; loaded) @@ -110,6 +110,6 @@ case $cmd in slots) # echo "Request slots" - ${MTX} -f $ctl status | grep " *Storage Changer" | awk "{print \$drive}" + ${MTX} -f $ctl status | grep " *Storage Changer" | awk "{print \$5}" ;; esac diff --git a/bacula/src/baconfig.h b/bacula/src/baconfig.h index 8aacd9c478..e1155c2d2a 100644 --- a/bacula/src/baconfig.h +++ b/bacula/src/baconfig.h @@ -487,4 +487,15 @@ extern "C" int getdomainname(char *name, int len); #define REPLACE_NEVER 'n' #define REPLACE_IFOLDER 'o' +#ifdef HAVE_SETLOCALE +#include +#else +#define setlocale(x, y) ("ANSI_X3.4-1968") +#endif +#ifdef HAVE_NL_LANGINFO +#include +#else +#define nl_langinfo(x) ("ANSI_X3.4-1968") +#endif + #endif /* _BACONFIG_H */ diff --git a/bacula/src/bacula.h b/bacula/src/bacula.h index 35f3c07ea1..54c355f42e 100644 --- a/bacula/src/bacula.h +++ b/bacula/src/bacula.h @@ -102,7 +102,7 @@ #include #include #include - + /* Local Bacula includes. Be sure to put all the system * includes before these. */ diff --git a/bacula/src/dird/dird_conf.c b/bacula/src/dird/dird_conf.c index 047f106e2d..d28007fa0c 100644 --- a/bacula/src/dird/dird_conf.c +++ b/bacula/src/dird/dird_conf.c @@ -561,20 +561,38 @@ void dump_resource(int type, RES *reshdr, void sendit(void *sock, char *fmt, ... } break; case R_FILESET: + { + int i, j, k; sendit(sock, "FileSet: name=%s\n", res->res_fs.hdr.name); - for (int i=0; ires_fs.num_includes; i++) { + for (i=0; ires_fs.num_includes; i++) { INCEXE *incexe = res->res_fs.include_items[i]; - for (int j=0; jname_list.size(); j++) { - sendit(sock, " Inc: %s\n", incexe->name_list.get(j)); + for (j=0; jnum_opts; j++) { + FOPTS *fo = incexe->opts_list[j]; + sendit(sock, " O %s\n", fo->opts); + for (k=0; kmatch.size(); k++) { + sendit(sock, " W %s\n", fo->match.get(j)); + } + sendit(sock, " N\n"); + } + for (j=0; jname_list.size(); j++) { + sendit(sock, " I %s\n", incexe->name_list.get(j)); + } + if (incexe->name_list.size()) { + sendit(sock, " N\n"); } } - for (int i=0; ires_fs.num_excludes; i++) { + + for (i=0; ires_fs.num_excludes; i++) { INCEXE *incexe = res->res_fs.exclude_items[i]; - for (int j=0; jname_list.size(); j++) { - sendit(sock, " Exc: %s\n", incexe->name_list.get(j)); + for (j=0; jname_list.size(); j++) { + sendit(sock, " E %s\n", incexe->name_list.get(j)); + } + if (incexe->name_list.size()) { + sendit(sock, " N\n"); } } break; + } case R_SCHEDULE: if (res->res_sch.run) { int i; diff --git a/bacula/src/dird/fd_cmds.c b/bacula/src/dird/fd_cmds.c index b3b6f3d760..2432151218 100644 --- a/bacula/src/dird/fd_cmds.c +++ b/bacula/src/dird/fd_cmds.c @@ -245,9 +245,11 @@ static int send_list(JCR *jcr, int list) } else { ie = fileset->exclude_items[i]; } - fo = ie->opts_list[0]; - for (int j=0; jmatch.size(); j++) { - Dmsg1(100, "Match=%s\n", fo->match.get(j)); + if (ie->num_opts) { + fo = ie->opts_list[0]; + for (int j=0; jmatch.size(); j++) { + Dmsg1(100, "Match=%s\n", fo->match.get(j)); + } } for (int j=0; jname_list.size(); j++) { p = (char *)ie->name_list.get(j); @@ -313,8 +315,8 @@ static int send_list(JCR *jcr, int list) p++; /* skip over \ */ /* Note, fall through wanted */ default: - Dmsg2(100, "numopts=%d opts=%s\n", ie->num_opts, NPRT(ie->opts_list[0]->opts)); if (ie->num_opts) { + Dmsg2(100, "numopts=%d opts=%s\n", ie->num_opts, NPRT(ie->opts_list[0]->opts)); pm_strcpy(&fd->msg, ie->opts_list[0]->opts); pm_strcat(&fd->msg, " "); } else { diff --git a/bacula/src/dird/inc_conf.c b/bacula/src/dird/inc_conf.c index 2488e67984..2c1413217e 100644 --- a/bacula/src/dird/inc_conf.c +++ b/bacula/src/dird/inc_conf.c @@ -37,6 +37,7 @@ static void store_newinc(LEX *lc, RES_ITEM *item, int index, int pass); static void store_match(LEX *lc, RES_ITEM *item, int index, int pass); static void store_opts(LEX *lc, RES_ITEM *item, int index, int pass); static void store_fname(LEX *lc, RES_ITEM *item, int index, int pass); +static void options_res(LEX *lc, RES_ITEM *item, int index, int pass); static void store_base(LEX *lc, RES_ITEM *item, int index, int pass); static void setup_current_opts(void); @@ -54,9 +55,18 @@ static INCEXE res_incexe; /* * new Include/Exclude items - * name handler value code flags default_value + * name handler value code flags default_value */ static RES_ITEM newinc_items[] = { + {"file", store_fname, NULL, 0, 0, 0}, + {"options", options_res, NULL, 0, 0, 0}, + {NULL, NULL, NULL, 0, 0, 0} +}; + +/* + * Items that are valid in an Options resource + */ +static RES_ITEM options_items[] = { {"compression", store_opts, NULL, 0, 0, 0}, {"signature", store_opts, NULL, 0, 0, 0}, {"verify", store_opts, NULL, 0, 0, 0}, @@ -67,11 +77,11 @@ static RES_ITEM newinc_items[] = { {"replace", store_opts, NULL, 0, 0, 0}, {"portable", store_opts, NULL, 0, 0, 0}, {"match", store_match, NULL, 0, 0, 0}, - {"file", store_fname, NULL, 0, 0, 0}, {"base", store_base, NULL, 0, 0, 0}, {NULL, NULL, NULL, 0, 0, 0} }; + /* Define FileSet KeyWord values */ #define INC_KW_NONE 0 @@ -162,6 +172,7 @@ static struct s_fs_opt FS_options[] = { * Scan for right hand side of Include options (keyword=option) is * converted into one or two characters. Verifyopts=xxxx is Vxxxx: * Whatever is found is concatenated to the opts string. + * This code is also used inside an Options resource. */ static void scan_include_options(LEX *lc, int keyword, char *opts, int optlen) { @@ -205,7 +216,10 @@ static void scan_include_options(LEX *lc, int keyword, char *opts, int optlen) } } -/* Store FileSet Include/Exclude info */ +/* + * + * Store FileSet Include/Exclude info + */ void store_inc(LEX *lc, RES_ITEM *item, int index, int pass) { int token, i; @@ -342,6 +356,7 @@ static void store_newinc(LEX *lc, RES_ITEM *item, int index, int pass) { int token, i; INCEXE *incexe; + bool options; if (!res_all.res_fs.have_MD5) { MD5Init(&res_all.res_fs.md5c); @@ -360,10 +375,13 @@ static void store_newinc(LEX *lc, RES_ITEM *item, int index, int pass) scan_err1(lc, _("Expecting keyword, got: %s\n"), lc->str); } for (i=0; newinc_items[i].name; i++) { + options = strcasecmp(lc->str, "options") == 0; if (strcasecmp(newinc_items[i].name, lc->str) == 0) { - token = lex_get_token(lc, T_ALL); - if (token != T_EQUALS) { - scan_err1(lc, "expected an equals, got: %s", lc->str); + if (!options) { + token = lex_get_token(lc, T_ALL); + if (token != T_EQUALS) { + scan_err1(lc, "expected an equals, got: %s", lc->str); + } } /* Call item handler */ newinc_items[i].handler(lc, &newinc_items[i], i, pass); @@ -483,6 +501,48 @@ static void store_fname(LEX *lc, RES_ITEM *item, int index, int pass) scan_to_eol(lc); } +/* + * Come here when Options seen in Include/Exclude + */ +static void options_res(LEX *lc, RES_ITEM *item, int index, int pass) +{ + int token, i; + + token = lex_get_token(lc, T_ALL); + if (token != T_BOB) { + scan_err1(lc, "Expecting open brace. Got %s", lc->str); + } + + while ((token = lex_get_token(lc, T_ALL)) != T_EOF) { + if (token == T_EOL) { + continue; + } + if (token == T_EOB) { + break; + } + if (token != T_IDENTIFIER) { + scan_err1(lc, _("Expecting keyword, got: %s\n"), lc->str); + } + for (i=0; options_items[i].name; i++) { + if (strcasecmp(options_items[i].name, lc->str) == 0) { + token = lex_get_token(lc, T_ALL); + if (token != T_EQUALS) { + scan_err1(lc, "expected an equals, got: %s", lc->str); + } + /* Call item handler */ + options_items[i].handler(lc, &options_items[i], i, pass); + i = -1; + break; + } + } + if (i >=0) { + scan_err1(lc, "Keyword %s not permitted in this resource", lc->str); + } + } + scan_to_eol(lc); +} + + /* * New style options come here */ @@ -508,7 +568,7 @@ static void store_opts(LEX *lc, RES_ITEM *item, int index, int pass) scan_include_options(lc, keyword, inc_opts, sizeof(inc_opts)); if (pass == 1) { setup_current_opts(); - bstrncpy(res_incexe.current_opts->opts, inc_opts, MAX_FOPTS); + bstrncat(res_incexe.current_opts->opts, inc_opts, MAX_FOPTS); Dmsg2(100, "new pass=%d incexe opts=%s\n", pass, res_incexe.current_opts->opts); } scan_to_eol(lc); diff --git a/bacula/src/version.h b/bacula/src/version.h index 9fbc00dc2c..b0630023f4 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -2,8 +2,8 @@ #undef VERSION #define VERSION "1.34.3" #define VSTRING "1" -#define BDATE "27 Apr 2004" -#define LSMDATE "27Apr04" +#define BDATE "28 Apr 2004" +#define LSMDATE "28Apr04" /* Debug flags */ #undef DEBUG diff --git a/bacula/src/win32/compat/winconfig.h b/bacula/src/win32/compat/winconfig.h index 5f0d78b269..eff32e4f3e 100644 --- a/bacula/src/win32/compat/winconfig.h +++ b/bacula/src/win32/compat/winconfig.h @@ -360,7 +360,9 @@ #define HAVE_SETENV 1 /* Define to 1 if you have the `setlocale' function. */ -#define HAVE_SETLOCALE 1 +#undef HAVE_SETLOCALE + +#undef HAVE_NL_LANGINFO /* Define to 1 if you have the `setpgid' function. */ #define HAVE_SETPGID 1 -- 2.39.5