core/source/logic/transfer/borg.ts

88 lines
1.8 KiB
TypeScript
Raw Normal View History

2025-09-24 12:39:22 +02:00
/*
This file is part of »mimir«.
Copyright 2025 kcf <fenris@folksprak.org>
»mimir« is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
»mimir« is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with »mimir«. If not, see <http://www.gnu.org/licenses/>.
*/
2025-03-24 22:47:55 +01:00
namespace _mimir.transfer.borg
{
/**
2025-09-24 12:39:22 +02:00
*/
export type type_parameters = {
repository : string;
compression : string;
pruning : {
keep_weekly : int;
keep_yearly : int;
}
};
/**
2025-03-24 22:47:55 +01:00
*/
export function execute(
2025-09-24 12:39:22 +02:00
parameters : type_parameters,
2025-03-24 22:47:55 +01:00
name : string,
stamp : string,
directory : string
) : Array<string>
{
const result : Array<string> = [];
result.push(
_mimir.helpers.borg.create(
parameters.repository,
lib_plankton.string.coin(
"{{stamp}}-{{name}}",
{
"name": name,
"stamp": stamp,
}
),
[directory],
{
"compression": parameters.compression,
}
)
);
result.push(
_mimir.helpers.borg.prune(
parameters.repository,
"2w",
{
2025-09-24 12:39:22 +02:00
"keep_weekly": parameters.pruning.keep_weekly,
"keep_yearly": parameters.pruning.keep_yearly,
2025-03-24 22:47:55 +01:00
}
)
);
return result;
}
2025-09-24 12:39:22 +02:00
/**
*/
export function logic(
parameters : type_parameters
) : _mimir.transfer.type_logic
{
return {
"execute": (name, stamp, directory) => execute(parameters, name, stamp, directory),
};
}
2025-03-24 22:47:55 +01:00
}