Compare commits
4 commits
62ba6d8fb7
...
b1fd941bb2
Author | SHA1 | Date | |
---|---|---|---|
|
b1fd941bb2 | ||
|
92ebed3b2e | ||
af12d13e25 | |||
12c66d1be7 |
3 changed files with 20 additions and 40 deletions
|
@ -1,4 +1,4 @@
|
||||||
{ lib, config, ... }: {
|
{ lib, config, pkgs, ... }: {
|
||||||
imports = [
|
imports = [
|
||||||
../../common
|
../../common
|
||||||
../../profiles/headless.nix
|
../../profiles/headless.nix
|
||||||
|
@ -30,10 +30,9 @@
|
||||||
|
|
||||||
backupPrepareCommand = ''
|
backupPrepareCommand = ''
|
||||||
umask 0077
|
umask 0077
|
||||||
rm -f -- ${pgBackup}
|
rm -f -- ${pgBackup}
|
||||||
${lib.getExe' config.services.postgresql.package "pg_dumpall"} \
|
su -c '${lib.getExe' config.services.postgresql.package "pg_dumpall"}' \
|
||||||
-U ${config.services.postgresql.superUser} \
|
${config.services.postgresql.superUser} >${pgBackup}
|
||||||
-f ${pgBackup}
|
|
||||||
'';
|
'';
|
||||||
|
|
||||||
backupCleanupCommand = ''
|
backupCleanupCommand = ''
|
||||||
|
|
24
flake.lock
24
flake.lock
|
@ -12,11 +12,11 @@
|
||||||
"nixpkgs-stable": "nixpkgs-stable"
|
"nixpkgs-stable": "nixpkgs-stable"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1731193172,
|
"lastModified": 1731270564,
|
||||||
"narHash": "sha256-Ykz7q58tF0wLTOjCxQMe5+jdAPPQ1dC8k39y9I/5k+I=",
|
"narHash": "sha256-6KMC/NH/VWP5Eb+hA56hz0urel3jP6Y6cF2PX6xaTkk=",
|
||||||
"owner": "zhaofengli",
|
"owner": "zhaofengli",
|
||||||
"repo": "attic",
|
"repo": "attic",
|
||||||
"rev": "a02bf38a7562e4041345a136aef6e5a4eb891bbb",
|
"rev": "47752427561f1c34debb16728a210d378f0ece36",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -562,11 +562,11 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1730837930,
|
"lastModified": 1731235328,
|
||||||
"narHash": "sha256-0kZL4m+bKBJUBQse0HanewWO0g8hDdCvBhudzxgehqc=",
|
"narHash": "sha256-NjavpgE9/bMe/ABvZpyHIUeYF1mqR5lhaep3wB79ucs=",
|
||||||
"owner": "nix-community",
|
"owner": "nix-community",
|
||||||
"repo": "home-manager",
|
"repo": "home-manager",
|
||||||
"rev": "2f607e07f3ac7e53541120536708e824acccfaa8",
|
"rev": "60bb110917844d354f3c18e05450606a435d2d10",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -946,11 +946,11 @@
|
||||||
},
|
},
|
||||||
"nixpkgs_4": {
|
"nixpkgs_4": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1730785428,
|
"lastModified": 1731139594,
|
||||||
"narHash": "sha256-Zwl8YgTVJTEum+L+0zVAWvXAGbWAuXHax3KzuejaDyo=",
|
"narHash": "sha256-IigrKK3vYRpUu+HEjPL/phrfh7Ox881er1UEsZvw9Q4=",
|
||||||
"owner": "nixos",
|
"owner": "nixos",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "4aa36568d413aca0ea84a1684d2d46f55dbabad7",
|
"rev": "76612b17c0ce71689921ca12d9ffdc9c23ce40b2",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -1059,11 +1059,11 @@
|
||||||
"nixpkgs-stable": "nixpkgs-stable_2"
|
"nixpkgs-stable": "nixpkgs-stable_2"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1731047660,
|
"lastModified": 1731213149,
|
||||||
"narHash": "sha256-iyp51lPWEQz4c5VH9bVbAuBcFP4crETU2QJYh5V0NYA=",
|
"narHash": "sha256-jR8i6nFLmSmm0cIoeRQ8Q4EBARa3oGaAtEER/OMMxus=",
|
||||||
"owner": "Mic92",
|
"owner": "Mic92",
|
||||||
"repo": "sops-nix",
|
"repo": "sops-nix",
|
||||||
"rev": "60e1bce1999f126e3b16ef45f89f72f0c3f8d16f",
|
"rev": "f1675e3b0e1e663a4af49be67ecbc9e749f85eb7",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
{ config, lib, pkgs, utils, ... }: let
|
{ config, lib, options, pkgs, ... }: let
|
||||||
cfg = config.kyouma.restic;
|
cfg = config.kyouma.restic;
|
||||||
in {
|
in {
|
||||||
options.kyouma.restic = let
|
options.kyouma.restic = let
|
||||||
inherit (lib) mkOption types;
|
inherit (lib) mkOption types;
|
||||||
in {
|
in {
|
||||||
|
inherit (options.services.restic.backups.type.getSubOptions [])
|
||||||
|
timerConfig backupPrepareCommand backupCleanupCommand;
|
||||||
enable = lib.mkEnableOption "Enable restic backup";
|
enable = lib.mkEnableOption "Enable restic backup";
|
||||||
paths = mkOption {
|
paths = mkOption {
|
||||||
description = "paths to backup";
|
description = "paths to backup";
|
||||||
|
@ -40,27 +42,6 @@ in {
|
||||||
type = types.nonEmptyStr;
|
type = types.nonEmptyStr;
|
||||||
default = "${config.networking.hostName}-backup";
|
default = "${config.networking.hostName}-backup";
|
||||||
};
|
};
|
||||||
timerConfig = mkOption {
|
|
||||||
description = "timer config";
|
|
||||||
type = with types; nullOr (attrsOf utils.systemdUtils.unitOptions.unitOption);
|
|
||||||
default = {
|
|
||||||
OnCalendar = "daily";
|
|
||||||
Persistent = true;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
# FIXME: Can these be just inherited?
|
|
||||||
backupPrepareCommand = mkOption {
|
|
||||||
description = "preparation script";
|
|
||||||
type = with types; nullOr str;
|
|
||||||
default = null;
|
|
||||||
};
|
|
||||||
|
|
||||||
backupCleanupCommand = mkOption {
|
|
||||||
description = "cleanup script";
|
|
||||||
type = with types; nullOr str;
|
|
||||||
default = null;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
config = lib.mkIf cfg.enable {
|
config = lib.mkIf cfg.enable {
|
||||||
sops.secrets."restic/${cfg.remoteUser}/password" = {
|
sops.secrets."restic/${cfg.remoteUser}/password" = {
|
||||||
|
@ -71,7 +52,7 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
services.restic.backups."${config.networking.hostName}-${cfg.remote}" = {
|
services.restic.backups."${config.networking.hostName}-${cfg.remote}" = {
|
||||||
inherit (cfg) paths user pruneOpts timerConfig;
|
inherit (cfg) paths user pruneOpts timerConfig backupPrepareCommand backupCleanupCommand;
|
||||||
initialize = true;
|
initialize = true;
|
||||||
repository = "sftp:${cfg.remoteUser}@${cfg.remote}:${cfg.repo}";
|
repository = "sftp:${cfg.remoteUser}@${cfg.remote}:${cfg.repo}";
|
||||||
passwordFile = config.sops.secrets."restic/${cfg.remoteUser}/password".path;
|
passwordFile = config.sops.secrets."restic/${cfg.remoteUser}/password".path;
|
||||||
|
|
Loading…
Reference in a new issue