return ret;
}
-bool Bvfs::compute_restore_list(char *fileid, char *dirid, char *output_table)
+bool Bvfs::compute_restore_list(char *fileid, char *dirid, char *fileindex, char *output_table)
{
POOL_MEM query;
POOL_MEM tmp, tmp2;
bool use_insert_hardlinks_fast = false;
/* check args */
- if ((*fileid && !is_a_number_list(fileid)) ||
- (*dirid && !is_a_number_list(dirid)) ||
- (!*fileid && !*dirid)|| (!output_table)
+ if ((fileid && *fileid && !is_a_number_list(fileid)) ||
+ (dirid && *dirid && !is_a_number_list(dirid)) ||
+ (fileindex && *fileindex && !is_a_number_list(fileindex)) ||
+ (!*fileid && !*dirid && (!fileindex || !*fileindex)) || (!output_table)
)
{
+ Dmsg0(dbglevel, "Invalid parameters\n");
return false;
}
if (!check_temp(output_table)) {
pm_strcat(query, tmp.c_str());
}
+ if (fileindex && *fileindex) { /* Select files with their fileindex */
+ int64_t jobid, fidx;
+ sellist sel;
+ sel.set_string(fileindex, true);
+
+ /* check the format */
+ foreach_sellist(jobid, &sel) {
+ fidx = sel.next();
+ if (fidx <= 0) {
+ goto bail_out;
+ }
+ if (init) {
+ query.strcat(" UNION ");
+ }
+ Mmsg(tmp,"SELECT Job.JobId, JobTDate, FileIndex, Filename, "
+ "PathId, FileId "
+ "FROM File JOIN Job USING (JobId) "
+ "WHERE JobId = %lld AND FileIndex = %lld AND JobId IN (%s) ",
+ jobid, fidx, jobids);
+
+ pm_strcat(query, tmp.c_str());
+ init=true;
+ }
+ }
+
/* Add a directory content */
while (get_next_id_from_list(&dirid, &id) == 1) {
Mmsg(tmp, "SELECT Path FROM Path WHERE PathId=%lld", id);
void clear_cache();
/* Compute restore list */
- bool compute_restore_list(char *fileid, char *dirid, char *output_table);
+ bool compute_restore_list(char *fileid, char *dirid, char *fileindex, char *output_table);
/* Drop previous restore list */
bool drop_restore_list(char *output_table);
return ret;
}
-/* .bvfs_restore path=b2XXXXX jobid=1,2 fileid=1,2 dirid=1,2 objectid=1,2
+/* .bvfs_restore path=b2XXXXX jobid=1,2 fileid=1,2 dirid=1,2 fileindex=fidx,jobid,fidx,jobid objectid=1,2
*/
static bool dot_bvfs_restore(UAContext *ua, const char *cmd)
{
DBId_t pathid=0;
int limit=2000, offset=0, i;
- char *path=NULL, *jobid = NULL, *username=NULL;
+ char *path=NULL, *jobid = NULL, *username=NULL, *fileindex=NULL;
db_list_ctx jobids, fileid, dirid;
bool object = false, ret = false;
}
fileid.add(ua->argv[i]);
}
+
if ((i = find_arg_with_value(ua, "dirid")) >= 0) {
if (ua->argv[i][0] != '\0' && !is_a_number_list(ua->argv[i])) {
ua->error_msg("Please provide dirid as a list of integers!\n");
dirid.add(ua->argv[i]);
}
+ if ((i = find_arg_with_value(ua, "fileindex")) >= 0) {
+ if (ua->argv[i][0] != '\0' && !is_a_number_list(ua->argv[i])) {
+ ua->error_msg("Please provide fileid as a list of integers!\n");
+ return true;
+ }
+
+ int64_t jobid, fidx;
+ sellist sel;
+ sel.set_string(ua->argv[i], true);
+
+ /* check the format */
+ foreach_sellist(jobid, &sel) {
+ fidx = sel.next();
+ if (fidx <= 0) {
+ ua->error_msg("Please provide jobid,fileindex as a list of integers!\n");
+ return true;
+ }
+ }
+ fileindex = ua->argv[i];
+ }
+
if (object) {
i = find_arg_with_value(ua, "objectid");
if (ua->argv[i][0] != '\0' && !is_a_number_list(ua->argv[i])) {
if ((i = find_arg(ua, "nodelta")) >= 0) {
fs.set_compute_delta(false);
}
- if (fs.compute_restore_list(fileid.list, dirid.list, path)) {
+ if (fs.compute_restore_list(fileid.list, dirid.list, fileindex, path)) {
ua->send_msg("OK\n");
} else {
ua->error_msg("Can't create restore list\n");