From: Eric Bollengier Date: Mon, 15 Dec 2008 17:51:32 +0000 (+0000) Subject: ebl Add patch to allow a more easy selection for restore X-Git-Tag: Release-7.0.0~3626 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=03812dd93439934bd22f00a1ef879e16ed19dbcc;p=bacula%2Fbacula ebl Add patch to allow a more easy selection for restore when using copy job git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@8169 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/patches/testing/restore_mediatype_storage_filter.patch b/bacula/patches/testing/restore_mediatype_storage_filter.patch new file mode 100644 index 0000000000..56e47f062e --- /dev/null +++ b/bacula/patches/testing/restore_mediatype_storage_filter.patch @@ -0,0 +1,151 @@ +Index: src/dird/ua.h +=================================================================== +--- src/dird/ua.h (revision 8163) ++++ src/dird/ua.h (working copy) +@@ -104,6 +104,7 @@ + JobId_t JobId; + char ClientName[MAX_NAME_LENGTH]; /* backup client */ + char RestoreClientName[MAX_NAME_LENGTH]; /* restore client */ ++ char MediaType[MAX_NAME_LENGTH]; /* mediatype filter */ + char last_jobid[20]; + POOLMEM *JobIds; /* User entered string of JobIds */ + STORE *store; +Index: src/dird/ua_restore.c +=================================================================== +--- src/dird/ua_restore.c (revision 8163) ++++ src/dird/ua_restore.c (working copy) +@@ -429,21 +429,23 @@ + "directory", /* 4 */ + "select", /* 5 */ + "pool", /* 6 */ +- "all", /* 7 */ ++ "storage", /* 7 */ ++ "mediatype", /* 8 */ ++ "all", /* 9 */ + + /* The keyword below are handled by individual arg lookups */ +- "client", /* 8 */ +- "storage", /* 9 */ +- "fileset", /* 10 */ +- "where", /* 11 */ +- "yes", /* 12 */ +- "bootstrap", /* 13 */ +- "done", /* 14 */ +- "strip_prefix", /* 15 */ +- "add_prefix", /* 16 */ +- "add_suffix", /* 17 */ +- "regexwhere", /* 18 */ +- "restoreclient", /* 19 */ ++ "client", /* 10 */ ++ "storage", /* 11 */ ++ "fileset", /* 12 */ ++ "where", /* 13 */ ++ "yes", /* 14 */ ++ "bootstrap", /* 15 */ ++ "done", /* 16 */ ++ "strip_prefix", /* 17 */ ++ "add_prefix", /* 18 */ ++ "add_suffix", /* 19 */ ++ "regexwhere", /* 20 */ ++ "restoreclient", /* 21 */ + NULL + }; + +@@ -531,7 +533,24 @@ + return 0; + } + break; +- case 7: /* all specified */ ++ case 7: /* storage */ ++ if (has_value(ua, i)) { ++ rx->store = (STORE *)GetResWithName(R_STORAGE, ua->argv[i]); ++ if (rx->store && !acl_access_ok(ua,Storage_ACL,rx->store->name())) { ++ rx->store = NULL; ++ } ++ } else { ++ rx->store = select_storage_resource(ua); ++ } ++ break; ++ case 8: /* mediatype */ ++ if (has_value(ua, i)) { ++ bstrncpy(rx->MediaType, ua->argv[i], sizeof(rx->MediaType)); ++ } else { ++ ua->error_msg(_("Invalid MediaType\n")); ++ } ++ break; ++ case 9: /* all specified */ + rx->all = true; + break; + /* +@@ -1140,7 +1159,8 @@ + CLIENT_DBR cr; + char fileset_name[MAX_NAME_LENGTH]; + char ed1[50], ed2[50]; +- char pool_select[MAX_NAME_LENGTH]; ++ POOL_MEM other_filter(PM_MESSAGE); ++ POOL_MEM temp_filter(PM_MESSAGE); + int i; + + /* Create temp tables */ +@@ -1196,23 +1216,38 @@ + } + + /* If Pool specified, add PoolId specification */ +- pool_select[0] = 0; + if (rx->pool) { ++ Dmsg1(0, "Use %s Pool filter\n", ++ rx->pool->name()); + POOL_DBR pr; + memset(&pr, 0, sizeof(pr)); + bstrncpy(pr.Name, rx->pool->name(), sizeof(pr.Name)); + if (db_get_pool_record(ua->jcr, ua->db, &pr)) { +- bsnprintf(pool_select, sizeof(pool_select), "AND Media.PoolId=%s ", +- edit_int64(pr.PoolId, ed1)); ++ Mmsg(other_filter, "AND Media.PoolId=%s ", ++ edit_int64(pr.PoolId, ed1)); + } else { + ua->warning_msg(_("Pool \"%s\" not found, using any pool.\n"), pr.Name); + } + } +- ++ /* use a storage filter */ ++ if (rx->store) { /* or use storageid ? */ ++ Mmsg(temp_filter, " AND Media.StorageId='%s' ", ++ edit_int64(rx->store->StorageId, ed1)); ++ pm_strcat(other_filter, temp_filter.c_str()); ++ Dmsg2(0, "Use %s StorageId filter (%s)\n", ++ rx->store->name(), ed1); ++ } ++ if (rx->MediaType[0]) { ++ Mmsg(temp_filter, " AND Media.MediaType='%s' ", ++ rx->MediaType); ++ pm_strcat(other_filter, temp_filter.c_str()); ++ Dmsg1(0, "Use mediatype filter (%s)\n", rx->MediaType); ++ } + /* Find JobId of last Full backup for this client, fileset */ + edit_int64(cr.ClientId, ed1); + Mmsg(rx->query, uar_last_full, ed1, ed1, date, fsr.FileSet, +- pool_select); ++ other_filter.c_str()); ++ Dmsg1(0, "q=%s\n", rx->query); + if (!db_sql_query(ua->db, rx->query, NULL, NULL)) { + ua->error_msg("%s\n", db_strerror(ua->db)); + goto bail_out; +@@ -1238,7 +1273,7 @@ + + /* Now find most recent Differental Job after Full save, if any */ + Mmsg(rx->query, uar_dif, edit_uint64(rx->JobTDate, ed1), date, +- edit_int64(cr.ClientId, ed2), fsr.FileSet, pool_select); ++ edit_int64(cr.ClientId, ed2), fsr.FileSet, other_filter.c_str()); + if (!db_sql_query(ua->db, rx->query, NULL, NULL)) { + ua->warning_msg("%s\n", db_strerror(ua->db)); + } +@@ -1254,7 +1289,7 @@ + + /* Now find all Incremental Jobs after Full/dif save */ + Mmsg(rx->query, uar_inc, edit_uint64(rx->JobTDate, ed1), date, +- edit_int64(cr.ClientId, ed2), fsr.FileSet, pool_select); ++ edit_int64(cr.ClientId, ed2), fsr.FileSet, other_filter.c_str()); + if (!db_sql_query(ua->db, rx->query, NULL, NULL)) { + ua->warning_msg("%s\n", db_strerror(ua->db)); + }