[mod] Umsetzung von borg-repokey-encryption
This commit is contained in:
parent
2816d2aade
commit
5d06f119cd
|
|
@ -7,6 +7,12 @@
|
||||||
"parameters": {
|
"parameters": {
|
||||||
"repository": "ssh://backup.example.org///repos/example",
|
"repository": "ssh://backup.example.org///repos/example",
|
||||||
"compression": "lz4",
|
"compression": "lz4",
|
||||||
|
"encryption": {
|
||||||
|
"kind": "repokey",
|
||||||
|
"data": {
|
||||||
|
"passphrase": "top_secret"
|
||||||
|
}
|
||||||
|
},
|
||||||
"pruning": {
|
"pruning": {
|
||||||
"keep_weekly": 1,
|
"keep_weekly": 1,
|
||||||
"keep_yearly": 2
|
"keep_yearly": 2
|
||||||
|
|
|
||||||
|
|
@ -101,6 +101,57 @@ namespace _mimir.conf
|
||||||
],
|
],
|
||||||
"default": "lz4"
|
"default": "lz4"
|
||||||
},
|
},
|
||||||
|
"encryption": {
|
||||||
|
"anyOf": [
|
||||||
|
{
|
||||||
|
"nullable": false,
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"kind": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": ["none"]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"additionalProperties": false,
|
||||||
|
"required": [
|
||||||
|
"kind"
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"nullable": false,
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"kind": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": ["repokey"]
|
||||||
|
},
|
||||||
|
"data": {
|
||||||
|
"nullable": true,
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"passphrase": {
|
||||||
|
"nullable": false,
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"additionalProperties": false,
|
||||||
|
"required": [
|
||||||
|
"passphrase"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"additionalProperties": false,
|
||||||
|
"required": [
|
||||||
|
"kind",
|
||||||
|
"data"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"default": {
|
||||||
|
"kind": "none",
|
||||||
|
"data": null
|
||||||
|
}
|
||||||
|
},
|
||||||
"pruning": {
|
"pruning": {
|
||||||
"nullable": false,
|
"nullable": false,
|
||||||
"type": "object",
|
"type": "object",
|
||||||
|
|
@ -287,15 +338,7 @@ namespace _mimir.conf
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
type type_target_parameters_borg = {
|
type type_target_parameters_borg = _mimir.transfer.borg.type_parameters;
|
||||||
repository : string;
|
|
||||||
compression : string;
|
|
||||||
pruning : {
|
|
||||||
keep_within : string;
|
|
||||||
keep_weekly : int;
|
|
||||||
keep_yearly : int;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -30,15 +30,29 @@ namespace _mimir.helpers.borg
|
||||||
repository_directory : string,
|
repository_directory : string,
|
||||||
{
|
{
|
||||||
"encryption": encryption = "none",
|
"encryption": encryption = "none",
|
||||||
|
"passphrase": passphrase = null,
|
||||||
} : {
|
} : {
|
||||||
encryption ?: string;
|
encryption ?: string;
|
||||||
|
passphrase ?: (null | string);
|
||||||
} = {
|
} = {
|
||||||
}
|
}
|
||||||
) : string
|
) : string
|
||||||
{
|
{
|
||||||
return lib_plankton.string.coin(
|
return lib_plankton.string.coin(
|
||||||
"borg init --encryption={{encryption}} {{repository_directory}}",
|
"{{macro_env_passphrase}}borg init --encryption={{encryption}} {{repository_directory}}",
|
||||||
{
|
{
|
||||||
|
"macro_env_passphrase": (
|
||||||
|
(passphrase === null)
|
||||||
|
?
|
||||||
|
""
|
||||||
|
:
|
||||||
|
lib_plankton.string.coin(
|
||||||
|
"BORG_PASSPHRASE='{{passphrase}}' BORG_DISPLAY_PASSPHRASE=n ",
|
||||||
|
{
|
||||||
|
"passphrase": passphrase,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
),
|
||||||
"repository_directory": repository_directory,
|
"repository_directory": repository_directory,
|
||||||
"encryption": encryption,
|
"encryption": encryption,
|
||||||
}
|
}
|
||||||
|
|
@ -54,15 +68,29 @@ namespace _mimir.helpers.borg
|
||||||
directories : Array<string>,
|
directories : Array<string>,
|
||||||
{
|
{
|
||||||
"compression": compression = "none",
|
"compression": compression = "none",
|
||||||
|
"passphrase": passphrase = null,
|
||||||
} : {
|
} : {
|
||||||
compression ?: string;
|
compression ?: string;
|
||||||
|
passphrase ?: (null | string);
|
||||||
} = {
|
} = {
|
||||||
}
|
}
|
||||||
) : string
|
) : string
|
||||||
{
|
{
|
||||||
return lib_plankton.string.coin(
|
return lib_plankton.string.coin(
|
||||||
"borg create --compression={{compression}} {{repository_directory}}::{{archive_name}} {{directories}}",
|
"{{macro_env_passphrase}}borg create --compression={{compression}} {{repository_directory}}::{{archive_name}} {{directories}}",
|
||||||
{
|
{
|
||||||
|
"macro_env_passphrase": (
|
||||||
|
(passphrase === null)
|
||||||
|
?
|
||||||
|
""
|
||||||
|
:
|
||||||
|
lib_plankton.string.coin(
|
||||||
|
"BORG_PASSPHRASE='{{passphrase}}' ",
|
||||||
|
{
|
||||||
|
"passphrase": passphrase,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
),
|
||||||
"repository_directory": repository_directory,
|
"repository_directory": repository_directory,
|
||||||
"archive_name": archive_name,
|
"archive_name": archive_name,
|
||||||
"compression": compression,
|
"compression": compression,
|
||||||
|
|
@ -80,16 +108,30 @@ namespace _mimir.helpers.borg
|
||||||
{
|
{
|
||||||
"keep_weekly": keep_weekly = null,
|
"keep_weekly": keep_weekly = null,
|
||||||
"keep_yearly": keep_yearly = null,
|
"keep_yearly": keep_yearly = null,
|
||||||
|
"passphrase": passphrase = null,
|
||||||
} : {
|
} : {
|
||||||
keep_weekly ?: (null | int);
|
keep_weekly ?: (null | int);
|
||||||
keep_yearly ?: (null | int);
|
keep_yearly ?: (null | int);
|
||||||
|
passphrase ?: (null | string);
|
||||||
} = {
|
} = {
|
||||||
}
|
}
|
||||||
) : string
|
) : string
|
||||||
{
|
{
|
||||||
return lib_plankton.string.coin(
|
return lib_plankton.string.coin(
|
||||||
"borg prune --keep-within={{keep_within}}{{macro_keep_weekly}}{{macro_keep_yearly}} {{repository_directory}}",
|
"{{macro_env_passphrase}}borg prune --keep-within={{keep_within}}{{macro_keep_weekly}}{{macro_keep_yearly}} {{repository_directory}}",
|
||||||
{
|
{
|
||||||
|
"macro_env_passphrase": (
|
||||||
|
(passphrase === null)
|
||||||
|
?
|
||||||
|
""
|
||||||
|
:
|
||||||
|
lib_plankton.string.coin(
|
||||||
|
"BORG_PASSPHRASE='{{passphrase}}' ",
|
||||||
|
{
|
||||||
|
"passphrase": passphrase,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
),
|
||||||
"repository_directory": repository_directory,
|
"repository_directory": repository_directory,
|
||||||
"keep_within": age,
|
"keep_within": age,
|
||||||
"macro_keep_weekly": (
|
"macro_keep_weekly": (
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,7 @@ namespace _mimir.transfer
|
||||||
{
|
{
|
||||||
"repository": target.parameters.repository,
|
"repository": target.parameters.repository,
|
||||||
"compression": target.parameters.compression,
|
"compression": target.parameters.compression,
|
||||||
|
"encryption": target.parameters.encryption,
|
||||||
"pruning": target.parameters.pruning,
|
"pruning": target.parameters.pruning,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -20,11 +20,40 @@ along with »mimir«. If not, see <http://www.gnu.org/licenses/>.
|
||||||
namespace _mimir.transfer.borg
|
namespace _mimir.transfer.borg
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
export type type_encryption = (
|
||||||
|
{
|
||||||
|
kind : "none";
|
||||||
|
data : {
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
|
||||||
|
{
|
||||||
|
kind : "repokey";
|
||||||
|
data : {
|
||||||
|
passphrase : string;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
|
|
||||||
|
{
|
||||||
|
kind : "keyfile";
|
||||||
|
data : {
|
||||||
|
path : string;
|
||||||
|
passphrase : string;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
export type type_parameters = {
|
export type type_parameters = {
|
||||||
repository : string;
|
repository : string;
|
||||||
compression : string;
|
compression : string;
|
||||||
|
encryption : type_encryption;
|
||||||
pruning : {
|
pruning : {
|
||||||
keep_within : string;
|
keep_within : string;
|
||||||
keep_weekly : int;
|
keep_weekly : int;
|
||||||
|
|
@ -55,6 +84,13 @@ namespace _mimir.transfer.borg
|
||||||
),
|
),
|
||||||
[directory],
|
[directory],
|
||||||
{
|
{
|
||||||
|
"passphrase": (
|
||||||
|
(parameters.encryption.kind === "repokey")
|
||||||
|
?
|
||||||
|
parameters.encryption.data.passphrase
|
||||||
|
:
|
||||||
|
null
|
||||||
|
),
|
||||||
"compression": parameters.compression,
|
"compression": parameters.compression,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue