- return 0;
- }
- db_list_sql_query(ua->db, ua->cmd, prtit, ua, 1);
- done = 0;
- break;
- case 4: /* Select the most recent backups */
- query = get_pool_memory(PM_MESSAGE);
- db_sql_query(ua->db, uar_del_temp, NULL, NULL);
- db_sql_query(ua->db, uar_del_temp1, NULL, NULL);
- if (!db_sql_query(ua->db, uar_create_temp, NULL, NULL)) {
- bsendmsg(ua, "%s\n", db_strerror(ua->db));
- }
- if (!db_sql_query(ua->db, uar_create_temp1, NULL, NULL)) {
- bsendmsg(ua, "%s\n", db_strerror(ua->db));
- }
- /*
- * Select Client
- */
- if (!(ji->client = get_client_resource(ua))) {
- return 0;
- }
-
- /*
- * Select FileSet
- */
- Mmsg(&query, uar_sel_fileset, ji->client->hdr.name);
- start_prompt(ua, _("The defined FileSet resources are:\n"));
- if (!db_sql_query(ua->db, query, fileset_handler, (void *)ua)) {
- bsendmsg(ua, "%s\n", db_strerror(ua->db));
- }
- if (do_prompt(ua, _("Select FileSet resource"),
- fileset_name, sizeof(fileset_name)) < 0) {
- free_pool_memory(query);
- return 0;
- }
- fsr.FileSetId = atoi(fileset_name); /* Id is first part of name */
- if (!db_get_fileset_record(ua->db, &fsr)) {
- bsendmsg(ua, "Error getting FileSet record: %s\n", db_strerror(ua->db));
- bsendmsg(ua, _("This probably means you modified the FileSet.\n"
- "Continuing anyway.\n"));
- }
-
- /* Find JobId of last Full backup for this client, fileset */
- Mmsg(&query, uar_last_full, ji->client->hdr.name, fsr.FileSetId);
- if (!db_sql_query(ua->db, query, NULL, NULL)) {
- bsendmsg(ua, "%s\n", db_strerror(ua->db));
- }
- /* Find all Volumes used by that JobId */
- if (!db_sql_query(ua->db, uar_full, NULL,NULL)) {
- bsendmsg(ua, "%s\n", db_strerror(ua->db));
- }
- /* Note, this is needed as I don't seem to get the callback
- * from the call just above.
- */
- if (!db_sql_query(ua->db, uar_sel_all_temp1, last_full_handler, (void *)ji)) {
- bsendmsg(ua, "%s\n", db_strerror(ua->db));
- }
- /* Now find all Incremental Jobs */
- Mmsg(&query, uar_inc, (uint32_t)ji->JobTDate, ji->ClientId, fsr.FileSetId);
- if (!db_sql_query(ua->db, query, NULL, NULL)) {
- bsendmsg(ua, "%s\n", db_strerror(ua->db));
- }
- free_pool_memory(query);
- db_list_sql_query(ua->db, uar_list_temp, prtit, ua, 1);
-
- if (!db_sql_query(ua->db, uar_sel_jobid_temp, jobid_handler, (void *)ji)) {
- bsendmsg(ua, "%s\n", db_strerror(ua->db));
- }
- db_sql_query(ua->db, uar_del_temp, NULL, NULL);
- db_sql_query(ua->db, uar_del_temp1, NULL, NULL);
- break;
- case 5:
- return 0;
+ return 0;
+ }
+ gui_save = ua->jcr->gui;
+ ua->jcr->gui = true;
+ db_list_sql_query(ua->jcr, ua->db, ua->cmd, prtit, ua, 1, HORZ_LIST);
+ ua->jcr->gui = gui_save;
+ done = false;
+ break;
+ case 4: /* Select the most recent backups */
+ if (!have_date) {
+ bstrutime(date, sizeof(date), now);
+ }
+ if (!select_backups_before_date(ua, rx, date)) {
+ return 0;
+ }
+ break;
+ case 5: /* select backup at specified time */
+ if (!have_date) {
+ if (!get_date(ua, date, sizeof(date))) {
+ return 0;
+ }
+ }
+ if (!select_backups_before_date(ua, rx, date)) {
+ return 0;
+ }
+ break;
+ case 6: /* Enter files */
+ if (!have_date) {
+ bstrutime(date, sizeof(date), now);
+ }
+ if (!get_client_name(ua, rx)) {
+ return 0;
+ }
+ ua->send_msg(_("Enter file names with paths, or < to enter a filename\n"
+ "containing a list of file names with paths, and terminate\n"
+ "them with a blank line.\n"));
+ for ( ;; ) {
+ if (!get_cmd(ua, _("Enter full filename: "))) {
+ return 0;
+ }
+ len = strlen(ua->cmd);
+ if (len == 0) {
+ break;
+ }
+ insert_one_file_or_dir(ua, rx, date, false);
+ }
+ return 2;
+ case 7: /* enter files backed up before specified time */
+ if (!have_date) {
+ if (!get_date(ua, date, sizeof(date))) {
+ return 0;
+ }
+ }
+ if (!get_client_name(ua, rx)) {
+ return 0;
+ }
+ ua->send_msg(_("Enter file names with paths, or < to enter a filename\n"
+ "containing a list of file names with paths, and terminate\n"
+ "them with a blank line.\n"));
+ for ( ;; ) {
+ if (!get_cmd(ua, _("Enter full filename: "))) {
+ return 0;
+ }
+ len = strlen(ua->cmd);
+ if (len == 0) {
+ break;
+ }
+ insert_one_file_or_dir(ua, rx, date, false);
+ }
+ return 2;
+
+ case 8: /* Find JobIds for current backup */
+ if (!have_date) {
+ bstrutime(date, sizeof(date), now);
+ }
+ if (!select_backups_before_date(ua, rx, date)) {
+ return 0;
+ }
+ done = false;
+ break;
+
+ case 9: /* Find JobIds for give date */
+ if (!have_date) {
+ if (!get_date(ua, date, sizeof(date))) {
+ return 0;
+ }
+ }
+ if (!select_backups_before_date(ua, rx, date)) {
+ return 0;
+ }
+ done = false;
+ break;
+
+ case 10: /* Enter directories */
+ if (*rx->JobIds != 0) {
+ ua->send_msg(_("You have already selected the following JobIds: %s\n"),
+ rx->JobIds);
+ } else if (get_cmd(ua, _("Enter JobId(s), comma separated, to restore: "))) {
+ if (*rx->JobIds != 0 && *ua->cmd) {
+ pm_strcat(rx->JobIds, ",");
+ }
+ pm_strcat(rx->JobIds, ua->cmd);
+ }
+ if (*rx->JobIds == 0 || *rx->JobIds == '.') {
+ return 0; /* nothing entered, return */
+ }
+ if (!have_date) {
+ bstrutime(date, sizeof(date), now);
+ }
+ if (!get_client_name(ua, rx)) {
+ return 0;
+ }
+ ua->send_msg(_("Enter full directory names or start the name\n"
+ "with a < to indicate it is a filename containing a list\n"
+ "of directories and terminate them with a blank line.\n"));
+ for ( ;; ) {
+ if (!get_cmd(ua, _("Enter directory name: "))) {
+ return 0;
+ }
+ len = strlen(ua->cmd);
+ if (len == 0) {
+ break;
+ }
+ /* Add trailing slash to end of directory names */
+ if (ua->cmd[0] != '<' && !IsPathSeparator(ua->cmd[len-1])) {
+ strcat(ua->cmd, "/");
+ }
+ insert_one_file_or_dir(ua, rx, date, true);
+ }
+ return 2;
+
+ case 11: /* Choose a jobid and select jobs */
+ if (!get_cmd(ua, _("Enter JobId to get the state to restore: ")) ||
+ !is_an_integer(ua->cmd))
+ {
+ return 0;
+ }
+
+ memset(&jr, 0, sizeof(JOB_DBR));
+ jr.JobId = str_to_int64(ua->cmd);
+ if (!db_get_job_record(ua->jcr, ua->db, &jr)) {
+ ua->error_msg(_("Unable to get Job record for JobId=%s: ERR=%s\n"),
+ ua->cmd, db_strerror(ua->db));
+ return 0;
+ }
+ ua->send_msg(_("Selecting jobs to build the Full state at %s\n"),
+ jr.cStartTime);
+ jr.JobLevel = L_INCREMENTAL; /* Take Full+Diff+Incr */
+ if (!db_accurate_get_jobids(ua->jcr, ua->db, &jr, &jobids)) {
+ return 0;
+ }
+ pm_strcpy(rx->JobIds, jobids.list);
+ Dmsg1(30, "Item 12: jobids = %s\n", rx->JobIds);
+ break;
+ case 12: /* Cancel or quit */
+ return 0;