parent
ef2ac47659
commit
13bee29b9b
@ -93,10 +93,12 @@ in
|
|||||||
};
|
};
|
||||||
|
|
||||||
paths = mkOption {
|
paths = mkOption {
|
||||||
type = types.listOf types.str;
|
type = types.nullOr (types.listOf types.str);
|
||||||
default = [];
|
default = null;
|
||||||
description = ''
|
description = ''
|
||||||
Which paths to backup.
|
Which paths to backup. If null or an empty array, no
|
||||||
|
backup command will be run. This can be used to create a
|
||||||
|
prune-only job.
|
||||||
'';
|
'';
|
||||||
example = [
|
example = [
|
||||||
"/var/lib/postgresql"
|
"/var/lib/postgresql"
|
||||||
@ -217,7 +219,7 @@ in
|
|||||||
resticCmd = "${pkgs.restic}/bin/restic${extraOptions}";
|
resticCmd = "${pkgs.restic}/bin/restic${extraOptions}";
|
||||||
filesFromTmpFile = "/run/restic-backups-${name}/includes";
|
filesFromTmpFile = "/run/restic-backups-${name}/includes";
|
||||||
backupPaths = if (backup.dynamicFilesFrom == null)
|
backupPaths = if (backup.dynamicFilesFrom == null)
|
||||||
then concatStringsSep " " backup.paths
|
then if (backup.paths != null) then concatStringsSep " " backup.paths else ""
|
||||||
else "--files-from ${filesFromTmpFile}";
|
else "--files-from ${filesFromTmpFile}";
|
||||||
pruneCmd = optionals (builtins.length backup.pruneOpts > 0) [
|
pruneCmd = optionals (builtins.length backup.pruneOpts > 0) [
|
||||||
( resticCmd + " forget --prune " + (concatStringsSep " " backup.pruneOpts) )
|
( resticCmd + " forget --prune " + (concatStringsSep " " backup.pruneOpts) )
|
||||||
@ -243,7 +245,8 @@ in
|
|||||||
restartIfChanged = false;
|
restartIfChanged = false;
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
Type = "oneshot";
|
Type = "oneshot";
|
||||||
ExecStart = [ "${resticCmd} backup --cache-dir=%C/restic-backups-${name} ${concatStringsSep " " backup.extraBackupArgs} ${backupPaths}" ] ++ pruneCmd;
|
ExecStart = (optionals (backupPaths != "") [ "${resticCmd} backup --cache-dir=%C/restic-backups-${name} ${concatStringsSep " " backup.extraBackupArgs} ${backupPaths}" ])
|
||||||
|
++ pruneCmd;
|
||||||
User = backup.user;
|
User = backup.user;
|
||||||
RuntimeDirectory = "restic-backups-${name}";
|
RuntimeDirectory = "restic-backups-${name}";
|
||||||
CacheDirectory = "restic-backups-${name}";
|
CacheDirectory = "restic-backups-${name}";
|
||||||
|
@ -45,6 +45,10 @@ import ./make-test-python.nix (
|
|||||||
'';
|
'';
|
||||||
inherit passwordFile initialize paths pruneOpts;
|
inherit passwordFile initialize paths pruneOpts;
|
||||||
};
|
};
|
||||||
|
remoteprune = {
|
||||||
|
inherit repository passwordFile;
|
||||||
|
pruneOpts = [ "--keep-last 1" ];
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
environment.sessionVariables.RCLONE_CONFIG_LOCAL_TYPE = "local";
|
environment.sessionVariables.RCLONE_CONFIG_LOCAL_TYPE = "local";
|
||||||
@ -84,6 +88,8 @@ import ./make-test-python.nix (
|
|||||||
"systemctl start restic-backups-rclonebackup.service",
|
"systemctl start restic-backups-rclonebackup.service",
|
||||||
'${pkgs.restic}/bin/restic -r ${repository} -p ${passwordFile} snapshots -c | grep -e "^4 snapshot"',
|
'${pkgs.restic}/bin/restic -r ${repository} -p ${passwordFile} snapshots -c | grep -e "^4 snapshot"',
|
||||||
'${pkgs.restic}/bin/restic -r ${rcloneRepository} -p ${passwordFile} snapshots -c | grep -e "^4 snapshot"',
|
'${pkgs.restic}/bin/restic -r ${rcloneRepository} -p ${passwordFile} snapshots -c | grep -e "^4 snapshot"',
|
||||||
|
"systemctl start restic-backups-remoteprune.service",
|
||||||
|
'${pkgs.restic}/bin/restic -r ${repository} -p ${passwordFile} snapshots -c | grep -e "^1 snapshot"',
|
||||||
)
|
)
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user