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]);
 
 STORE *select_storage_resource(UAContext *ua)
 {
    char name[MAX_NAME_LENGTH];   
-   STORE *store = NULL;
+   STORE *store;
 
    start_prompt(ua, _("The defined Storage resources are:\n"));
    LockRes();
-   while ((store = (STORE *)GetNextRes(R_STORAGE, (RES *)store))) {
+   foreach_res(store, R_STORAGE) {
       add_prompt(ua, store->hdr.name);
    }
    UnlockRes();
 FILESET *select_fileset_resource(UAContext *ua)
 {
    char name[MAX_NAME_LENGTH];   
-   FILESET *fs = NULL;
+   FILESET *fs;
 
    start_prompt(ua, _("The defined FileSet resources are:\n"));
    LockRes();
-   while ((fs = (FILESET *)GetNextRes(R_FILESET, (RES *)fs))) {
+   foreach_res(fs, R_FILESET) {
       add_prompt(ua, fs->hdr.name);
    }
    UnlockRes();
    if (!catalog) {
       start_prompt(ua, _("The defined Catalog resources are:\n"));
       LockRes();
-      while ((catalog = (CAT *)GetNextRes(R_CATALOG, (RES *)catalog))) {
+      foreach_res(catalog, R_CATALOG) {
         add_prompt(ua, catalog->hdr.name);
       }
       UnlockRes();
 JOB *select_job_resource(UAContext *ua)
 {
    char name[MAX_NAME_LENGTH];   
-   JOB *job = NULL;
+   JOB *job;
 
    start_prompt(ua, _("The defined Job resources are:\n"));
    LockRes();
-   while ( (job = (JOB *)GetNextRes(R_JOB, (RES *)job)) ) {
+   foreach_res(job, R_JOB) {
       add_prompt(ua, job->hdr.name);
    }
    UnlockRes();
 JOB *select_restore_job_resource(UAContext *ua)
 {
    char name[MAX_NAME_LENGTH];   
-   JOB *job = NULL;
+   JOB *job;
 
    start_prompt(ua, _("The defined Restore Job resources are:\n"));
    LockRes();
-   while ( (job = (JOB *)GetNextRes(R_JOB, (RES *)job)) ) {
+   foreach_res(job, R_JOB) {
       if (job->JobType == JT_RESTORE) {
         add_prompt(ua, job->hdr.name);
       }
 CLIENT *select_client_resource(UAContext *ua)
 {
    char name[MAX_NAME_LENGTH];   
-   CLIENT *client = NULL;
+   CLIENT *client;
 
    start_prompt(ua, _("The defined Client resources are:\n"));
    LockRes();
-   while ( (client = (CLIENT *)GetNextRes(R_CLIENT, (RES *)client)) ) {
+   foreach_res(client, R_CLIENT) {
       add_prompt(ua, client->hdr.name);
    }
    UnlockRes();
            strcasecmp(ua->argk[i], _("fd")) == 0) && ua->argv[i]) {
         bstrncpy(cr->Name, ua->argv[i], sizeof(cr->Name));
         if (!db_get_client_record(ua->jcr, ua->db, cr)) {
-            bsendmsg(ua, _("Could not find Client %s: ERR=%s"), ua->argv[i],
+            bsendmsg(ua, _("Could not find Client \"%s\": ERR=%s"), ua->argv[i],
                     db_strerror(ua->db));
            cr->ClientId = 0;
            break;
    bstrncpy(ocr.Name, name, sizeof(ocr.Name));
 
    if (!db_get_client_record(ua->jcr, ua->db, &ocr)) {
-      bsendmsg(ua, _("Could not find Client %s: ERR=%s"), name, db_strerror(ua->db));
+      bsendmsg(ua, _("Could not find Client \"%s\": ERR=%s"), name, db_strerror(ua->db));
       return 0;
    }
    memcpy(cr, &ocr, sizeof(ocr));
       if (db_get_pool_record(ua->jcr, ua->db, pr)) {
         return pr->PoolId;
       }
-      bsendmsg(ua, _("Could not find Pool %s: ERR=%s"), pr->Name, db_strerror(ua->db));
+      bsendmsg(ua, _("Could not find Pool \"%s\": ERR=%s"), pr->Name, db_strerror(ua->db));
    }
    if (!select_pool_dbr(ua, pr)) {  /* try once more */
       return 0;
       if (strcasecmp(ua->argk[i], _("pool")) == 0 && ua->argv[i]) {
         bstrncpy(pr->Name, ua->argv[i], sizeof(pr->Name));
         if (!db_get_pool_record(ua->jcr, ua->db, pr)) {
-            bsendmsg(ua, _("Could not find Pool %s: ERR=%s"), ua->argv[i],
+            bsendmsg(ua, _("Could not find Pool \"%s\": ERR=%s"), ua->argv[i],
                     db_strerror(ua->db));
            pr->PoolId = 0;
            break;
    bstrncpy(opr.Name, name, sizeof(opr.Name));
 
    if (!db_get_pool_record(ua->jcr, ua->db, &opr)) {
-      bsendmsg(ua, _("Could not find Pool %s: ERR=%s"), name, db_strerror(ua->db));
+      bsendmsg(ua, _("Could not find Pool \"%s\": ERR=%s"), name, db_strerror(ua->db));
       return 0;
    }
    memcpy(pr, &opr, sizeof(opr));
 POOL *select_pool_resource(UAContext *ua)
 {
    char name[MAX_NAME_LENGTH];   
-   POOL *pool = NULL;
+   POOL *pool;
 
    start_prompt(ua, _("The defined Pool resources are:\n"));
    LockRes();
-   while ((pool = (POOL *)GetNextRes(R_POOL, (RES *)pool))) {
+   foreach_res(pool, R_POOL) {
       add_prompt(ua, pool->hdr.name);
    }
    UnlockRes();
       if (pool) {
         return pool;
       }
-      bsendmsg(ua, _("Error: Pool resource %s does not exist.\n"), ua->argv[i]);
+      bsendmsg(ua, _("Error: Pool resource \"%s\" does not exist.\n"), ua->argv[i]);
    }
    return select_pool_resource(ua);
 }
         continue;
       }
       if (!db_get_job_record(ua->jcr, ua->db, jr)) {
-         bsendmsg(ua, _("Could not find Job %s: ERR=%s"), ua->argv[i],
+         bsendmsg(ua, _("Could not find Job \"%s\": ERR=%s"), ua->argv[i],
                  db_strerror(ua->db));
         jr->JobId = 0;
         break;
 
          } else if (strcasecmp(ua->argk[i], _("job")) == 0) {
            if (!(jcr=get_jcr_by_partial_name(ua->argv[i]))) {
-               bsendmsg(ua, _("Job %s is not running.\n"), ua->argv[i]);
+               bsendmsg(ua, _("Job \"%s\" is not running.\n"), ua->argv[i]);
               return NULL;
            }
            store = jcr->store;
    if (!store && store_name) {
       store = (STORE *)GetResWithName(R_STORAGE, store_name);
       if (!store) {
-         bsendmsg(ua, "Storage resource %s: not found\n", store_name);
+         bsendmsg(ua, "Storage resource \"%s\": not found\n", store_name);
       }
    }
    /* No keywords found, so present a selection list */