api: tape/restore: add namespace mapping
by adding a new parameter 'namespaces', which contains a mapping for a namespace like this: store=datastore,source=foo,target=bar,max-depth=2 if source or target are omitted the root namespace is used for its value this mapping can be given several times (on the cli) or as an array (via api) to have mappings for multiple datastores if a specific snapshot list is given simultaneously, the given snapshots will be restored according to this mapping, or to the source namespace if no mapping was found. to do this, we reutilize the restore_list_worker, but change it so that it does not hold a lock for the duration of the restore, but fails if the snapshot does exist at the end. also the snapshot will now be temporarily restored into the target datastore into the '.tmp/<media-set-uuid>' folder. Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
@ -36,6 +36,14 @@ macro_rules! BACKUP_NS_RE {
|
||||
);
|
||||
}
|
||||
|
||||
#[rustfmt::skip]
|
||||
#[macro_export]
|
||||
macro_rules! BACKUP_NS_PATH_RE {
|
||||
() => (
|
||||
concat!(r"(?:ns/", PROXMOX_SAFE_ID_REGEX_STR!(), r"/){0,7}ns/", PROXMOX_SAFE_ID_REGEX_STR!(), r"/")
|
||||
);
|
||||
}
|
||||
|
||||
#[rustfmt::skip]
|
||||
#[macro_export]
|
||||
macro_rules! SNAPSHOT_PATH_REGEX_STR {
|
||||
|
@ -30,7 +30,7 @@ use proxmox_uuid::Uuid;
|
||||
use crate::{BackupType, BACKUP_ID_SCHEMA, FINGERPRINT_SHA256_FORMAT};
|
||||
|
||||
const_regex! {
|
||||
pub TAPE_RESTORE_SNAPSHOT_REGEX = concat!(r"^", PROXMOX_SAFE_ID_REGEX_STR!(), r":", SNAPSHOT_PATH_REGEX_STR!(), r"$");
|
||||
pub TAPE_RESTORE_SNAPSHOT_REGEX = concat!(r"^", PROXMOX_SAFE_ID_REGEX_STR!(), r":(:?", BACKUP_NS_PATH_RE!(),")?", SNAPSHOT_PATH_REGEX_STR!(), r"$");
|
||||
}
|
||||
|
||||
pub const TAPE_RESTORE_SNAPSHOT_FORMAT: ApiStringFormat =
|
||||
@ -42,9 +42,9 @@ pub const TAPE_ENCRYPTION_KEY_FINGERPRINT_SCHEMA: Schema =
|
||||
.schema();
|
||||
|
||||
pub const TAPE_RESTORE_SNAPSHOT_SCHEMA: Schema =
|
||||
StringSchema::new("A snapshot in the format: 'store:type/id/time")
|
||||
StringSchema::new("A snapshot in the format: 'store:[ns/namespace/...]type/id/time")
|
||||
.format(&TAPE_RESTORE_SNAPSHOT_FORMAT)
|
||||
.type_text("store:type/id/time")
|
||||
.type_text("store:[ns/namespace/...]type/id/time")
|
||||
.schema();
|
||||
|
||||
#[api(
|
||||
|
Reference in New Issue
Block a user