char *date);
static void insert_one_file_or_dir(UAContext *ua, RESTORE_CTX *rx, char *date, bool dir);
static int get_client_name(UAContext *ua, RESTORE_CTX *rx);
+static int get_restore_client_name(UAContext *ua, RESTORE_CTX &rx);
static int get_date(UAContext *ua, char *date, int date_len);
static int restore_count_handler(void *ctx, int num_fields, char **row);
static bool insert_table_into_findex_list(UAContext *ua, RESTORE_CTX *rx, char *table);
ua->error_msg(_("No Client resource found!\n"));
goto bail_out;
}
+ get_restore_client_name(ua, rx);
escaped_bsr_name = escape_filename(jcr->RestoreBootstrap);
if (rx.RegexWhere) {
escaped_where_name = escape_filename(rx.RegexWhere);
Mmsg(ua->cmd,
- "run job=\"%s\" client=\"%s\" storage=\"%s\" bootstrap=\"%s\""
- " regexwhere=\"%s\" files=%d catalog=\"%s\"",
- job->name(), rx.ClientName, rx.store?rx.store->name():"",
+ "run job=\"%s\" client=\"%s\" restoreclient=\"%s\" storage=\"%s\""
+ " bootstrap=\"%s\" regexwhere=\"%s\" files=%d catalog=\"%s\"",
+ job->name(), rx.ClientName, rx.RestoreClientName,
+ rx.store?rx.store->name():"",
escaped_bsr_name ? escaped_bsr_name : jcr->RestoreBootstrap,
escaped_where_name ? escaped_where_name : rx.RegexWhere,
rx.selected_files, ua->catalog->name());
} else if (rx.where) {
escaped_where_name = escape_filename(rx.where);
Mmsg(ua->cmd,
- "run job=\"%s\" client=\"%s\" storage=\"%s\" bootstrap=\"%s\""
- " where=\"%s\" files=%d catalog=\"%s\"",
- job->name(), rx.ClientName, rx.store?rx.store->name():"",
+ "run job=\"%s\" client=\"%s\" restoreclient=\"%s\" storage=\"%s\""
+ " bootstrap=\"%s\" where=\"%s\" files=%d catalog=\"%s\"",
+ job->name(), rx.ClientName, rx.RestoreClientName,
+ rx.store?rx.store->name():"",
escaped_bsr_name ? escaped_bsr_name : jcr->RestoreBootstrap,
escaped_where_name ? escaped_where_name : rx.where,
rx.selected_files, ua->catalog->name());
} else {
Mmsg(ua->cmd,
- "run job=\"%s\" client=\"%s\" storage=\"%s\" bootstrap=\"%s\""
- " files=%d catalog=\"%s\"",
- job->name(), rx.ClientName, rx.store?rx.store->name():"",
+ "run job=\"%s\" client=\"%s\" restoreclient=\"%s\" storage=\"%s\""
+ " bootstrap=\"%s\" files=%d catalog=\"%s\"",
+ job->name(), rx.ClientName, rx.RestoreClientName,
+ rx.store?rx.store->name():"",
escaped_bsr_name ? escaped_bsr_name : jcr->RestoreBootstrap,
rx.selected_files, ua->catalog->name());
}
return true;
}
+/*
+ * This gets the client name from which the backup was made
+ */
static int get_client_name(UAContext *ua, RESTORE_CTX *rx)
{
/* If no client name specified yet, get it now */
CLIENT_DBR cr;
/* try command line argument */
int i = find_arg_with_value(ua, NT_("client"));
+ if (i < 0) {
+ i = find_arg_with_value(ua, NT_("backupclient"));
+ }
if (i >= 0) {
if (!has_value(ua, i)) {
return 0;
return 1;
}
+/*
+ * This is where we pick up a client name to restore to.
+ */
+static int get_restore_client_name(UAContext *ua, RESTORE_CTX &rx)
+{
+ /* Start with same name as backup client */
+ bstrncpy(rx.RestoreClientName, rx.ClientName, sizeof(rx.RestoreClientName));
+
+ /* try command line argument */
+ int i = find_arg_with_value(ua, NT_("restoreclient"));
+ if (i >= 0) {
+ if (!has_value(ua, i)) {
+ return 0;
+ }
+ bstrncpy(rx.RestoreClientName, ua->argv[i], sizeof(rx.RestoreClientName));
+ return 1;
+ }
+ return 1;
+}
+
+
/*
* The first step in the restore process is for the user to
have_date = true;
break;
case 2: /* before */
- if (!has_value(ua, i)) {
+ if (have_date || !has_value(ua, i)) {
return 0;
}
if (str_to_utime(ua->argv[i]) == 0) {
done = false;
break;
case 4: /* Select the most recent backups */
- bstrutime(date, sizeof(date), now);
+ 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 (!get_date(ua, date, sizeof(date))) {
- return 0;
+ 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 */
- bstrutime(date, sizeof(date), now);
+ if (!have_date) {
+ bstrutime(date, sizeof(date), now);
+ }
if (!get_client_name(ua, rx)) {
return 0;
}
}
return 2;
case 7: /* enter files backed up before specified time */
- if (!get_date(ua, date, sizeof(date))) {
- return 0;
+ if (!have_date) {
+ if (!get_date(ua, date, sizeof(date))) {
+ return 0;
+ }
}
if (!get_client_name(ua, rx)) {
return 0;
return 2;
case 8: /* Find JobIds for current backup */
- bstrutime(date, sizeof(date), now);
+ if (!have_date) {
+ bstrutime(date, sizeof(date), now);
+ }
if (!select_backups_before_date(ua, rx, date)) {
return 0;
}
break;
case 9: /* Find JobIds for give date */
- if (!get_date(ua, date, sizeof(date))) {
- return 0;
+ if (!have_date) {
+ if (!get_date(ua, date, sizeof(date))) {
+ return 0;
+ }
}
if (!select_backups_before_date(ua, rx, date)) {
return 0;
if (*rx->JobIds == 0 || *rx->JobIds == '.') {
return 0; /* nothing entered, return */
}
- bstrutime(date, sizeof(date), now);
+ if (!have_date) {
+ bstrutime(date, sizeof(date), now);
+ }
if (!get_client_name(ua, rx)) {
return 0;
}
if ((ffd = fopen(p, "rb")) == NULL) {
berrno be;
ua->error_msg(_("Cannot open file %s: ERR=%s\n"),
- p, be.strerror());
+ p, be.bstrerror());
break;
}
while (fgets(file, sizeof(file), ffd)) {
char pool_select[MAX_NAME_LENGTH];
int i;
-
/* Create temp tables */
db_sql_query(ua->db, uar_del_temp, NULL, NULL);
db_sql_query(ua->db, uar_del_temp1, NULL, NULL);
ua->error_msg("%s\n", db_strerror(ua->db));
goto bail_out;
}
+
/* Note, this is needed because I don't seem to get the callback
* from the call just above.
*/