From: Eric Bollengier Date: Tue, 24 Oct 2017 12:10:43 +0000 (+0200) Subject: Add "noautoparent" restore command option to disable the automatic parent directory... X-Git-Tag: Release-9.0.6~52 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=045379fb5636d86e362c46da60f0edfcb705f6f1;p=bacula%2Fbacula Add "noautoparent" restore command option to disable the automatic parent directory selection At this time, when we select a directory, we mark parent directories for the restore automatically. In the NDMP restore process, at this time, when we select a directory entry, the entire content is restored recursively. This option can be used to not select automatically parent directories during a restore session. --- diff --git a/bacula/src/dird/ua.h b/bacula/src/dird/ua.h index 6f8bc3718c..6e93966c7c 100644 --- a/bacula/src/dird/ua.h +++ b/bacula/src/dird/ua.h @@ -80,6 +80,7 @@ struct TREE_CTX { int cnt; /* count for user feedback */ bool all; /* if set mark all as default */ bool hardlinks_in_mem; /* Set to optimize for speed */ + bool no_auto_parent; /* Set to not select parent directories */ UAContext *ua; uint32_t FileEstimate; /* estimate of number of files */ uint32_t FileCount; /* current count of files */ @@ -133,6 +134,7 @@ struct RESTORE_CTX { bool all; /* mark all as default */ bool hardlinks_in_mem; /* keep hard links in memory */ bool fdcalled; /* True if we should reuse the FD socket */ + bool no_auto_parent; /* Select or not parent directories */ NAME_LIST name_list; POOLMEM *component_fname; FILE *component_fd; diff --git a/bacula/src/dird/ua_cmds.c b/bacula/src/dird/ua_cmds.c index 78b0bd66f9..870cc7691c 100644 --- a/bacula/src/dird/ua_cmds.c +++ b/bacula/src/dird/ua_cmds.c @@ -143,7 +143,7 @@ static struct cmdstruct commands[] = { /* C { NT_("query"), query_cmd, _("Query catalog"), NT_("[]"), false}, { NT_("restore"), restore_cmd, _("Restore files"), NT_("where= client= storage= bootstrap= " - "restorejob= restoreclient=" + "restorejob= restoreclient= noautoparent" "\n\tcomment= jobid= jobuser= jobgroup= copies done select all"), false}, { NT_("relabel"), relabel_cmd, _("Relabel a tape"), diff --git a/bacula/src/dird/ua_restore.c b/bacula/src/dird/ua_restore.c index 29257625a7..892a20d8b7 100644 --- a/bacula/src/dird/ua_restore.c +++ b/bacula/src/dird/ua_restore.c @@ -109,8 +109,10 @@ int restore_cmd(UAContext *ua, const char *cmd) for (i = 0; i < ua->argc ; i++) { if (strcasecmp(ua->argk[i], "fdcalled") == 0) { rx.fdcalled = true; - } + } else if (strcasecmp(ua->argk[i], "noautoparent") == 0) { + rx.no_auto_parent = true; + } if (!ua->argv[i]) { continue; /* skip if no value given */ } @@ -537,7 +539,7 @@ static int user_select_jobids_or_files(UAContext *ua, RESTORE_CTX *rx) "xxxxxxxxx", /* 24 */ "fdcalled", /* 25 */ "when", /* 26 */ - + "noautoparent", /* 27 */ NULL }; @@ -1245,6 +1247,7 @@ static bool build_directory_tree(UAContext *ua, RESTORE_CTX *rx) tree.ua = ua; tree.all = rx->all; tree.hardlinks_in_mem = rx->hardlinks_in_mem; + tree.no_auto_parent = rx->no_auto_parent; last_JobId = 0; tree.last_dir_acl = NULL; /* diff --git a/bacula/src/dird/ua_tree.c b/bacula/src/dird/ua_tree.c index 3ca5d51717..a03eb1b158 100644 --- a/bacula/src/dird/ua_tree.c +++ b/bacula/src/dird/ua_tree.c @@ -317,7 +317,7 @@ static int set_extract(UAContext *ua, TREE_NODE *node, TREE_CTX *tree, bool extr * Walk up tree marking any unextracted parent to be * extracted. */ - if (extract) { + if (!tree->no_auto_parent && extract) { while (node->parent && !node->parent->extract_dir) { node = node->parent; node->extract_dir = true;