2022-01-18 21:29:30 +01:00
|
|
|
{
|
2022-03-10 21:52:12 +01:00
|
|
|
pkgs,
|
|
|
|
|
config,
|
2025-12-25 14:00:03 +01:00
|
|
|
lib,
|
2022-03-10 21:52:12 +01:00
|
|
|
...
|
2025-12-25 14:00:03 +01:00
|
|
|
}:
|
|
|
|
|
{
|
2022-01-18 21:29:30 +01:00
|
|
|
services.restic.backups.niveum = {
|
|
|
|
|
initialize = true;
|
2025-12-25 14:00:03 +01:00
|
|
|
repository = pkgs.lib.niveum.restic.repository;
|
2022-03-10 21:52:12 +01:00
|
|
|
timerConfig = {
|
|
|
|
|
OnCalendar = "8:00";
|
|
|
|
|
RandomizedDelaySec = "1h";
|
|
|
|
|
};
|
2023-02-22 10:02:55 +01:00
|
|
|
passwordFile = config.age.secrets.restic.path;
|
2022-01-18 23:36:38 +01:00
|
|
|
extraBackupArgs = [
|
2024-04-03 07:56:07 +02:00
|
|
|
"--exclude=/home/kfm/sync/src/nixpkgs/.git"
|
2022-01-18 23:36:38 +01:00
|
|
|
"--exclude=node_modules"
|
2023-07-25 16:17:23 +02:00
|
|
|
"--exclude=.parcel-cache"
|
2022-01-18 23:36:38 +01:00
|
|
|
];
|
2022-01-18 21:29:30 +01:00
|
|
|
paths = [
|
2024-04-03 07:56:07 +02:00
|
|
|
"/home/kfm/sync"
|
|
|
|
|
"/home/kfm/state"
|
2022-01-19 00:48:15 +01:00
|
|
|
"/home/kfm/cloud"
|
2024-04-05 11:41:13 +02:00
|
|
|
"/home/kfm/mobile"
|
2022-01-19 00:48:15 +01:00
|
|
|
"/home/kfm/.gnupg"
|
2024-11-13 06:13:40 +01:00
|
|
|
"/home/kfm/.electrum"
|
2022-01-19 00:48:15 +01:00
|
|
|
"/home/kfm/.ssh"
|
2022-01-18 21:29:30 +01:00
|
|
|
];
|
|
|
|
|
};
|
2022-01-18 22:38:28 +01:00
|
|
|
|
2022-01-24 09:13:58 +01:00
|
|
|
systemd.services.restic-backups-niveum.serviceConfig = {
|
|
|
|
|
Restart = "on-failure";
|
|
|
|
|
RestartSec = "15s";
|
|
|
|
|
StartLimitIntervalSec = "1m"; # don't try more than 4 times
|
|
|
|
|
StartLimitBurst = 4;
|
|
|
|
|
};
|
2022-01-22 09:18:38 +01:00
|
|
|
|
2022-01-18 22:38:28 +01:00
|
|
|
environment.systemPackages = [
|
|
|
|
|
(pkgs.writers.writeDashBin "restic-niveum" ''
|
2025-12-25 14:00:03 +01:00
|
|
|
${pkgs.restic}/bin/restic -r ${pkgs.lib.niveum.restic.repository} -p ${config.age.secrets.restic.path} "$@"
|
2022-01-18 22:38:28 +01:00
|
|
|
'')
|
2022-01-19 09:38:19 +01:00
|
|
|
(pkgs.writers.writeDashBin "restic-mount" ''
|
2025-12-27 07:29:47 +01:00
|
|
|
mountdir=$(mktemp -p "$XDG_RUNTIME_DIR" -d "restic-mount-XXXXXXX")
|
2022-01-19 09:38:19 +01:00
|
|
|
trap clean EXIT
|
|
|
|
|
clean() {
|
2022-01-23 14:26:54 +01:00
|
|
|
rm -r "$mountdir"
|
2022-01-19 09:38:19 +01:00
|
|
|
}
|
2025-12-25 14:00:03 +01:00
|
|
|
${pkgs.restic}/bin/restic -r ${pkgs.lib.niveum.restic.repository} -p ${config.age.secrets.restic.path} mount "$mountdir"
|
2022-01-19 09:38:19 +01:00
|
|
|
'')
|
2022-01-18 22:38:28 +01:00
|
|
|
];
|
2022-01-18 21:29:30 +01:00
|
|
|
}
|