- 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 from the Catalog
- */
- memset(&cr, 0, sizeof(cr));
- if (!get_client_dbr(ua, &cr)) {
- free_pool_memory(query);
- db_sql_query(ua->db, uar_del_temp, NULL, NULL);
- db_sql_query(ua->db, uar_del_temp1, NULL, NULL);
- return 0;
- }
- bstrncpy(ji->ClientName, cr.Name, sizeof(ji->ClientName));
-
- /*
- * Select FileSet
- */
- Mmsg(&query, uar_sel_fileset, cr.ClientId, cr.ClientId);
- 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);
- db_sql_query(ua->db, uar_del_temp, NULL, NULL);
- db_sql_query(ua->db, uar_del_temp1, NULL, NULL);
- 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, cr.ClientId, cr.ClientId, 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, edit_uint64(ji->JobTDate, ed1), cr.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: /* Cancel or quit */
+ return 0;