extern void print_bsr(UAContext *ua, RBSR *bsr);
/* Imported variables */
-extern char *uar_list_jobs, *uar_file, *uar_sel_files;
-extern char *uar_del_temp, *uar_del_temp1, *uar_create_temp;
-extern char *uar_create_temp1, *uar_last_full, *uar_full;
-extern char *uar_inc_dec, *uar_list_temp, *uar_sel_jobid_temp;
-extern char *uar_sel_all_temp1, *uar_sel_fileset, *uar_mediatype;
+extern char *uar_list_jobs, *uar_file, *uar_sel_files;
+extern char *uar_del_temp, *uar_del_temp1, *uar_create_temp;
+extern char *uar_create_temp1, *uar_last_full, *uar_full;
+extern char *uar_inc_dec, *uar_list_temp, *uar_sel_jobid_temp;
+extern char *uar_sel_all_temp1, *uar_sel_fileset, *uar_mediatype;
extern char *uar_jobid_fileindex;
POOLMEM *JobIds; /* User entered string of JobIds */
STORE *store;
JOB *restore_job;
+ POOL *pool;
int restore_jobs;
uint32_t selected_files;
char *where;
"before", /* 2 */
"file", /* 3 */
"select", /* 4 */
+ "pool", /* 5 */
NULL
};
}
done = true;
break;
+ case 5: /* pool specified */
+ i = find_arg_with_value(ua, "pool");
+ if (i >= 0) {
+ rx->pool = (POOL *)GetResWithName(R_POOL, ua->argv[i]);
+ } else {
+ bsendmsg(ua, _("Error: Pool resource \"%s\" does not exist.\n"), ua->argv[i]);
+ }
+ break;
default:
break;
}
}
jr.JobId = JobId;
if (!db_get_job_record(ua->jcr, ua->db, &jr)) {
- bsendmsg(ua, _("Unable to get Job record. ERR=%s\n"), db_strerror(ua->db));
+ bsendmsg(ua, _("Unable to get Job record for JobId=%u: ERR=%s\n"),
+ JobId, db_strerror(ua->db));
return 0;
}
rx->TotalFiles += jr.JobFiles;
return 1;
}
+/*
+ * Get date from user
+ */
static int get_date(UAContext *ua, char *date, int date_len)
{
bsendmsg(ua, _("The restored files will the most current backup\n"
return 1;
}
+/*
+ * Insert a single file, or read a list of files from a file
+ */
static void insert_one_file(UAContext *ua, RESTORE_CTX *rx, char *date)
{
FILE *ffd;
CLIENT_DBR cr;
char fileset_name[MAX_NAME_LENGTH];
char ed1[50];
+ char pool_select[MAX_NAME_LENGTH];
int i;
}
}
+ /* If Pool specified, add PoolId specification */
+ pool_select[0] = 0;
+ if (rx->pool) {
+ POOL_DBR pr;
+ memset(&pr, 0, sizeof(pr));
+ bstrncpy(pr.Name, rx->pool->hdr.name, sizeof(pr.Name));
+ if (db_get_pool_record(ua->jcr, ua->db, &pr)) {
+ bsnprintf(pool_select, sizeof(pool_select), "AND Media.PoolId=%u ", pr.PoolId);
+ } else {
+ bsendmsg(ua, _("Pool \"%s\" not found, using any pool.\n"), pr.Name);
+ }
+ }
/* Find JobId of last Full backup for this client, fileset */
- Mmsg(&rx->query, uar_last_full, cr.ClientId, cr.ClientId, date, fsr.FileSet);
+ Mmsg(&rx->query, uar_last_full, cr.ClientId, cr.ClientId, date, fsr.FileSet,
+ pool_select);
if (!db_sql_query(ua->db, rx->query, NULL, NULL)) {
bsendmsg(ua, "%s\n", db_strerror(ua->db));
goto bail_out;
/* Now find all Incremental/Decremental Jobs after Full save */
Mmsg(&rx->query, uar_inc_dec, edit_uint64(rx->JobTDate, ed1), date,
- cr.ClientId, fsr.FileSet);
+ cr.ClientId, fsr.FileSet, pool_select);
if (!db_sql_query(ua->db, rx->query, NULL, NULL)) {
bsendmsg(ua, "%s\n", db_strerror(ua->db));
}
{
RESTORE_CTX *rx = (RESTORE_CTX *)ctx;
- rx->JobTDate = strtoll(row[1], NULL, 10);
-
+ rx->JobTDate = str_to_int64(row[1]);
return 0;
}
*/
static int fileset_handler(void *ctx, int num_fields, char **row)
{
-
/* row[0] = FileSet (name) */
if (row[0]) {
add_prompt((UAContext *)ctx, row[0]);