1
0
mirror of https://github.com/kmein/niveum synced 2026-03-16 10:11:08 +01:00
Files
niveum/configs/backup.nix

38 lines
1003 B
Nix
Raw Normal View History

2022-01-18 22:38:28 +01:00
{ pkgs, config, ... }:
let
inherit (import <niveum/lib>) restic;
2022-01-18 22:38:28 +01:00
in
2022-01-18 21:29:30 +01:00
{
services.restic.backups.niveum = {
initialize = true;
inherit (restic) repository;
2022-01-19 22:01:26 +01:00
timerConfig = { OnCalendar = "8:00"; RandomizedDelaySec = "1h"; };
2022-01-18 21:29:30 +01:00
passwordFile = toString <secrets/restic/password>;
2022-01-18 23:36:38 +01:00
extraBackupArgs = [
2022-01-19 00:48:15 +01:00
"--exclude=/home/kfm/projects/nixpkgs/.git"
2022-01-18 23:36:38 +01:00
"--exclude=node_modules"
];
2022-01-18 21:29:30 +01:00
paths = [
"/home/kfm/work"
2022-01-18 23:36:38 +01:00
"/home/kfm/projects"
2022-01-19 00:48:15 +01:00
"/home/kfm/cloud"
"/home/kfm/.gnupg"
"/home/kfm/.ssh"
2022-01-18 21:29:30 +01:00
];
};
2022-01-18 22:38:28 +01:00
environment.systemPackages = [
(pkgs.writers.writeDashBin "restic-niveum" ''
${pkgs.restic}/bin/restic -r ${restic.repository} -p ${<secrets/restic/password>} "$@"
2022-01-18 22:38:28 +01:00
'')
2022-01-19 09:38:19 +01:00
(pkgs.writers.writeDashBin "restic-mount" ''
mountdir=$(mktemp -d)
trap clean EXIT
clean() {
rm "$mountdir"
}
${pkgs.restic}/bin/restic -r ${restic.repository} -p ${<secrets/restic/password>} mount "$mountdir"
'')
2022-01-18 22:38:28 +01:00
];
2022-01-18 21:29:30 +01:00
}