Skip to content

Commit 1f74ab2

Browse files
committed
revisit nix managed backups
1 parent a3e83eb commit 1f74ab2

File tree

8 files changed

+44
-13
lines changed

8 files changed

+44
-13
lines changed

hosts/common/impermanence.nix

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
"/var/lib/bluetooth" # blueman connections
2323
"/var/lib/nixos" # uid and gid mappings
2424
"/var/log" # logs
25-
"/var/lib/rancher/k3s" # k3s cluster
2625
"/var/lib/docker" # docker rootful
2726
];
2827
files = [

hosts/hyperion/default.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
../services/matrix.nix
99
../services/miniflux.nix
1010
../services/prometheus.nix
11+
../services/restic-rest.nix
1112
inputs.wunschkonzert-install.include
1213
];
1314
}

hosts/services/prometheus.nix

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,19 @@
7575
}
7676
];
7777
}
78+
{
79+
job_name = "restic-server";
80+
static_configs = [
81+
{
82+
targets = [
83+
"localhost:8000"
84+
];
85+
labels = {
86+
host = "${hostname}";
87+
};
88+
}
89+
];
90+
}
7891
];
7992
};
8093

hosts/services/restic-rest.nix

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{...}: {
2+
services.restic.server = {
3+
enable = true;
4+
prometheus = true;
5+
htpasswd-file = "/var/lib/restic/htpasswd";
6+
extraFlags = [
7+
"--no-auth"
8+
];
9+
};
10+
11+
# no firewall rule means only accessible on trusted interfaces, i.e. lo and tailscale
12+
13+
environment.persistence."/nix/persist" = {
14+
directories = [
15+
"/var/lib/restic"
16+
];
17+
};
18+
}

hosts/simmons/backup.nix

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,18 @@
33
pkgs,
44
...
55
}: {
6-
environment.systemPackages = with pkgs; [
7-
restic
8-
];
6+
age.secrets.restic_password = {
7+
file = ../../secrets/restic_password.age;
8+
owner = "danieln";
9+
};
910

1011
services.restic.backups.daily = {
1112
initialize = true;
12-
rcloneConfigFile = config.age.secrets.restic_rclone_config.path;
1313
passwordFile = config.age.secrets.restic_password.path;
1414
paths = ["/nix/persist"];
1515
exclude = [
1616
"var/log"
17+
"home/danieln/go" # golang cache
1718
"home/danieln/scratch" # random repos
1819
"home/danieln/downloads" # random crap
1920
"home/danieln/.local/share/Steam" # steam and its games
@@ -23,8 +24,13 @@
2324
"home/danieln/.config/Slack" # slack syncs itself
2425
"home/danieln/.mozilla" # nothing that firefox sync won't cover
2526
"home/danieln/.config/TeamSpeak" # nothing of value
27+
"home/danieln/code/*/.cache" # direnv caches etc
28+
# huge repo that I don't care about
29+
"home/danieln/code/qmk"
30+
"home/danieln/code/qmk_firmware"
31+
"home/danieln/code/Garmin"
2632
];
27-
repository = "rclone:b2:danieln-backups/simmons";
33+
repository = "rest:http://hyperion.squirrel-emperor.ts.net:8000/${config.networking.hostName}";
2834
timerConfig = {
2935
OnCalendar = "daily";
3036
Persistent = true;
@@ -35,9 +41,4 @@
3541
"--keep-yearly 10"
3642
];
3743
};
38-
39-
systemd.services.restic-backups-daily = {
40-
wants = ["network.target"];
41-
after = ["network.target"];
42-
};
4344
}

hosts/simmons/default.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{...}: {
22
imports = [
3-
#./backup.nix
3+
./backup.nix
44
./boot.nix
55
./steam.nix
66
];

secrets/restic_rclone_config.age

-540 Bytes
Binary file not shown.

secrets/secrets.nix

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ let
55
all = [simmons hyperion lusus];
66
in {
77
"password.age".publicKeys = all;
8-
"restic_rclone_config.age".publicKeys = all;
98
"restic_password.age".publicKeys = all;
109
"tailscale.age".publicKeys = all;
1110
"grafana.age".publicKeys = all;

0 commit comments

Comments
 (0)