2 ===================================================================
3 --- src/dird/ua.h (revision 8163)
4 +++ src/dird/ua.h (working copy)
7 char ClientName[MAX_NAME_LENGTH]; /* backup client */
8 char RestoreClientName[MAX_NAME_LENGTH]; /* restore client */
9 + char MediaType[MAX_NAME_LENGTH]; /* mediatype filter */
11 POOLMEM *JobIds; /* User entered string of JobIds */
13 Index: src/dird/ua_restore.c
14 ===================================================================
15 --- src/dird/ua_restore.c (revision 8163)
16 +++ src/dird/ua_restore.c (working copy)
23 + "mediatype", /* 8 */
26 /* The keyword below are handled by individual arg lookups */
32 - "bootstrap", /* 13 */
34 - "strip_prefix", /* 15 */
35 - "add_prefix", /* 16 */
36 - "add_suffix", /* 17 */
37 - "regexwhere", /* 18 */
38 - "restoreclient", /* 19 */
44 + "bootstrap", /* 15 */
46 + "strip_prefix", /* 17 */
47 + "add_prefix", /* 18 */
48 + "add_suffix", /* 19 */
49 + "regexwhere", /* 20 */
50 + "restoreclient", /* 21 */
58 - case 7: /* all specified */
59 + case 7: /* storage */
60 + if (has_value(ua, i)) {
61 + rx->store = (STORE *)GetResWithName(R_STORAGE, ua->argv[i]);
62 + if (rx->store && !acl_access_ok(ua,Storage_ACL,rx->store->name())) {
66 + rx->store = select_storage_resource(ua);
69 + case 8: /* mediatype */
70 + if (has_value(ua, i)) {
71 + bstrncpy(rx->MediaType, ua->argv[i], sizeof(rx->MediaType));
73 + ua->error_msg(_("Invalid MediaType\n"));
76 + case 9: /* all specified */
82 char fileset_name[MAX_NAME_LENGTH];
83 char ed1[50], ed2[50];
84 - char pool_select[MAX_NAME_LENGTH];
85 + POOL_MEM other_filter(PM_MESSAGE);
86 + POOL_MEM temp_filter(PM_MESSAGE);
89 /* Create temp tables */
90 @@ -1196,23 +1216,38 @@
93 /* If Pool specified, add PoolId specification */
96 + Dmsg1(0, "Use %s Pool filter\n",
99 memset(&pr, 0, sizeof(pr));
100 bstrncpy(pr.Name, rx->pool->name(), sizeof(pr.Name));
101 if (db_get_pool_record(ua->jcr, ua->db, &pr)) {
102 - bsnprintf(pool_select, sizeof(pool_select), "AND Media.PoolId=%s ",
103 - edit_int64(pr.PoolId, ed1));
104 + Mmsg(other_filter, "AND Media.PoolId=%s ",
105 + edit_int64(pr.PoolId, ed1));
107 ua->warning_msg(_("Pool \"%s\" not found, using any pool.\n"), pr.Name);
111 + /* use a storage filter */
112 + if (rx->store) { /* or use storageid ? */
113 + Mmsg(temp_filter, " AND Media.StorageId=%s ",
114 + edit_int64(rx->store->StorageId, ed1));
115 + pm_strcat(other_filter, temp_filter.c_str());
116 + Dmsg2(0, "Use %s StorageId filter (%s)\n",
117 + rx->store->name(), ed1);
119 + if (rx->MediaType[0]) {
120 + Mmsg(temp_filter, " AND Media.MediaType='%s' ",
122 + pm_strcat(other_filter, temp_filter.c_str());
123 + Dmsg1(0, "Use mediatype filter (%s)\n", rx->MediaType);
125 /* Find JobId of last Full backup for this client, fileset */
126 edit_int64(cr.ClientId, ed1);
127 Mmsg(rx->query, uar_last_full, ed1, ed1, date, fsr.FileSet,
129 + other_filter.c_str());
130 + Dmsg1(0, "q=%s\n", rx->query);
131 if (!db_sql_query(ua->db, rx->query, NULL, NULL)) {
132 ua->error_msg("%s\n", db_strerror(ua->db));
134 @@ -1238,7 +1273,7 @@
136 /* Now find most recent Differental Job after Full save, if any */
137 Mmsg(rx->query, uar_dif, edit_uint64(rx->JobTDate, ed1), date,
138 - edit_int64(cr.ClientId, ed2), fsr.FileSet, pool_select);
139 + edit_int64(cr.ClientId, ed2), fsr.FileSet, other_filter.c_str());
140 if (!db_sql_query(ua->db, rx->query, NULL, NULL)) {
141 ua->warning_msg("%s\n", db_strerror(ua->db));
143 @@ -1254,7 +1289,7 @@
145 /* Now find all Incremental Jobs after Full/dif save */
146 Mmsg(rx->query, uar_inc, edit_uint64(rx->JobTDate, ed1), date,
147 - edit_int64(cr.ClientId, ed2), fsr.FileSet, pool_select);
148 + edit_int64(cr.ClientId, ed2), fsr.FileSet, other_filter.c_str());
149 if (!db_sql_query(ua->db, rx->query, NULL, NULL)) {
150 ua->warning_msg("%s\n", db_strerror(ua->db));