nixos-config/services/restic/home-server.nix

61 lines
1.2 KiB
Nix
Raw Normal View History

2024-05-26 16:45:38 +02:00
{
config,
lib,
pkgs,
...
}:
2021-03-21 15:55:57 +01:00
2021-08-04 22:27:47 +02:00
# using the restic cli:
2022-05-09 12:26:12 +02:00
# load credentials into shell by adding B2 secrets to .env (see .env.example).
2021-08-04 22:27:47 +02:00
# useful commands for analysing restic stats [snapshot-id], restic diff [s1] [s2],
2021-03-21 15:55:57 +01:00
with lib;
with builtins;
2024-05-26 16:45:38 +02:00
let
resticLib = import ./lib.nix { inherit config lib pkgs; };
in
{
imports = [ ./common.nix ];
2021-05-12 23:22:52 +02:00
environment.systemPackages = with pkgs; [ restic ];
services.restic.backups.full = resticLib.resticConfig {
name = "home-server";
2024-05-26 16:45:38 +02:00
paths = [
"/etc/nixos"
"/var/lib"
"/home"
];
ignorePatterns = [
"/var/lib/systemd"
"/var/lib/containers"
2022-08-12 12:30:01 +02:00
"/var/lib/nixos-containers"
"/var/lib/lxcfs"
"/var/lib/docker"
"/var/lib/flatpak"
2022-07-04 17:11:44 +02:00
"/home/*/ignore"
"/home/*/.cache"
"/home/*/.local/share/containers"
"/home/*/.local/share/Trash"
"/var/lib/jellyfin/transcodes"
2022-08-15 21:05:58 +02:00
# general
".cache"
"cache"
".tmp"
".temp"
"tmp"
"temp"
".log"
"log"
".Trash"
];
timerConfig.OnCalendar = "0/6:00:00";
extraPruneOpts = [ "--keep-last 4" ];
backupPrepareCommand = ''
# remove stale locks
${pkgs.restic}/bin/restic unlock || true
'';
2021-03-21 14:24:35 +01:00
};
}