/** * @todo consider to outsource to plankton */ namespace _mimir.helpers.borg { /** */ export function init( repository_directory : string, { "encryption": encryption = "none", } : { encryption ?: string; } = { } ) : string { return lib_plankton.string.coin( "borg init --encryption={{encryption}} {{repository_directory}}", { "repository_directory": repository_directory, "encryption": encryption, } ); } /** */ export function create( repository_directory : string, archive_name : string, directories : Array, { "compression": compression = "none", } : { compression ?: string; } = { } ) : string { return lib_plankton.string.coin( "borg create --compression={{compression}} {{repository_directory}}::{{archive_name}} {{directories}}", { "repository_directory": repository_directory, "archive_name": archive_name, "compression": compression, "directories": directories.join(" "), } ) } /** */ export function prune( repository_directory : string, age : string, { "keep_weekly": keep_weekly = null, "keep_yearly": keep_yearly = null, } : { keep_weekly ?: (null | int); keep_yearly ?: (null | int); } = { } ) : string { return lib_plankton.string.coin( "borg prune --keep-within=2w{{macro_keep_weekly}}{{macro_keep_yearly}} {{repository_directory}}", { "repository_directory": repository_directory, "keep_within": age, "macro_keep_weekly": ( (keep_weekly === null) ? "" : lib_plankton.string.coin( " --keep-weekly={{x}}", {"x": keep_weekly.toFixed(0)} ) ), "macro_keep_yearly": ( (keep_yearly === null) ? "" : lib_plankton.string.coin( " --keep-yearly={{x}}", {"x": keep_yearly.toFixed(0)} ) ), } ) } }