mirror of
https://git.proxmox.com/git/proxmox-backup
synced 2025-08-08 16:44:43 +00:00
proxmox-backup-client: added ignore-acls/xattrs/ownership/permissions & overwrite parameters
If ignore-acls/ignore-xattrs/ignore-ownership/ignore-permissions is set, the corresponding flag gets removed. overwrite is saved as an PxarExtractOption like allow-existing-dirs. Signed-off-by: Markus Frank <m.frank@proxmox.com>
This commit is contained in:
parent
e90d5401ff
commit
10cc2a13b2
@ -1188,6 +1188,7 @@ We do not extract '.pxar' archives when writing to standard output.
|
|||||||
type: Boolean,
|
type: Boolean,
|
||||||
description: "Do not fail if directories already exists.",
|
description: "Do not fail if directories already exists.",
|
||||||
optional: true,
|
optional: true,
|
||||||
|
default: false,
|
||||||
},
|
},
|
||||||
keyfile: {
|
keyfile: {
|
||||||
schema: KEYFILE_SCHEMA,
|
schema: KEYFILE_SCHEMA,
|
||||||
@ -1201,15 +1202,51 @@ We do not extract '.pxar' archives when writing to standard output.
|
|||||||
type: CryptMode,
|
type: CryptMode,
|
||||||
optional: true,
|
optional: true,
|
||||||
},
|
},
|
||||||
|
"ignore-acls": {
|
||||||
|
type: Boolean,
|
||||||
|
description: "ignore acl settings",
|
||||||
|
optional: true,
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
|
"ignore-xattrs": {
|
||||||
|
type: Boolean,
|
||||||
|
description: "ignore xattr settings",
|
||||||
|
optional: true,
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
|
"ignore-ownership": {
|
||||||
|
type: Boolean,
|
||||||
|
description: "ignore owner settings (no chown)",
|
||||||
|
optional: true,
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
|
"ignore-permissions": {
|
||||||
|
type: Boolean,
|
||||||
|
description: "ignore permission settings (no chmod)",
|
||||||
|
optional: true,
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
|
"overwrite": {
|
||||||
|
type: Boolean,
|
||||||
|
description: "overwrite already existing files",
|
||||||
|
optional: true,
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)]
|
)]
|
||||||
/// Restore backup repository.
|
/// Restore backup repository.
|
||||||
async fn restore(param: Value) -> Result<Value, Error> {
|
async fn restore(
|
||||||
|
param: Value,
|
||||||
|
allow_existing_dirs: bool,
|
||||||
|
ignore_acls: bool,
|
||||||
|
ignore_xattrs: bool,
|
||||||
|
ignore_ownership: bool,
|
||||||
|
ignore_permissions: bool,
|
||||||
|
overwrite: bool
|
||||||
|
) -> Result<Value, Error> {
|
||||||
let repo = extract_repository_from_value(¶m)?;
|
let repo = extract_repository_from_value(¶m)?;
|
||||||
|
|
||||||
let allow_existing_dirs = param["allow-existing-dirs"].as_bool().unwrap_or(false);
|
|
||||||
|
|
||||||
let archive_name = json::required_string_param(¶m, "archive-name")?;
|
let archive_name = json::required_string_param(¶m, "archive-name")?;
|
||||||
|
|
||||||
let rate = match param["rate"].as_str() {
|
let rate = match param["rate"].as_str() {
|
||||||
@ -1331,14 +1368,30 @@ async fn restore(param: Value) -> Result<Value, Error> {
|
|||||||
match_list: &[],
|
match_list: &[],
|
||||||
extract_match_default: true,
|
extract_match_default: true,
|
||||||
allow_existing_dirs,
|
allow_existing_dirs,
|
||||||
|
overwrite,
|
||||||
on_error: None,
|
on_error: None,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let mut feature_flags = pbs_client::pxar::Flags::DEFAULT;
|
||||||
|
|
||||||
|
if ignore_acls {
|
||||||
|
feature_flags.remove(pbs_client::pxar::Flags::WITH_ACL);
|
||||||
|
}
|
||||||
|
if ignore_xattrs {
|
||||||
|
feature_flags.remove(pbs_client::pxar::Flags::WITH_XATTRS);
|
||||||
|
}
|
||||||
|
if ignore_ownership {
|
||||||
|
feature_flags.remove(pbs_client::pxar::Flags::WITH_OWNER);
|
||||||
|
}
|
||||||
|
if ignore_permissions {
|
||||||
|
feature_flags.remove(pbs_client::pxar::Flags::WITH_PERMISSIONS);
|
||||||
|
}
|
||||||
|
|
||||||
if let Some(target) = target {
|
if let Some(target) = target {
|
||||||
pbs_client::pxar::extract_archive(
|
pbs_client::pxar::extract_archive(
|
||||||
pxar::decoder::Decoder::from_std(reader)?,
|
pxar::decoder::Decoder::from_std(reader)?,
|
||||||
Path::new(target),
|
Path::new(target),
|
||||||
pbs_client::pxar::Flags::DEFAULT,
|
feature_flags,
|
||||||
|path| {
|
|path| {
|
||||||
log::debug!("{:?}", path);
|
log::debug!("{:?}", path);
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user