nixos-config/systems/nasty/snapraid.nix

136 lines
3.7 KiB
Nix
Raw Normal View History

2025-11-10 14:22:01 +01:00
{ pkgs, ... }:
2024-08-28 00:00:10 +02:00
let
excludes = [
"/media/usenet/incomplete/"
2025-11-10 14:22:01 +01:00
"/.snapshot/"
];
snapshot-path = [
pkgs.bash
pkgs.btrfs-progs
2024-08-28 00:00:10 +02:00
];
in
{
#systemd.timers."snapraid-sync".enable = false; #temporarily
2025-11-10 14:22:01 +01:00
#systemd.timers."snapraid-scrub".enable = false; #temporarily
systemd.services."snapraid-sync" = {
serviceConfig = {
ReadWritePaths = [
"/mnt/snapshot/ZVV0688G/.snapshot/"
"/mnt/snapshot/ZVV072JR/.snapshot/"
"/mnt/snapshot/ZXA0FSKT/.snapshot/"
"/mnt/snapshot/92F0A079FJDH/.snapshot/"
2025-11-24 10:55:54 +01:00
"/mnt/snapshot/53G0A2AXFJDH/.snapshot/"
"/mnt/snapshot/53J0A016FJDH/.snapshot/"
2025-11-10 14:22:01 +01:00
"/mnt/snapshot/X2N0A0AXFJDH/.snapshot/"
2025-11-24 10:55:54 +01:00
"/mnt/snapshot/X2N0A0AZFJDH/.snapshot/"
2025-11-10 14:22:01 +01:00
"/mnt/snapshot/ZA1D9307/.snapshot/"
"/mnt/snapshot/1EJZN6MZ/.snapshot/"
"/mnt/snapshot/1EKR513Z/.snapshot/"
"/mnt/snapshot/1EKVK21Z/.snapshot/"
];
};
unitConfig.After = "snapraid-pre.service";
unitConfig.Before = "snapraid-post.service";
wants = [
"snapraid-pre.service"
"snapraid-post.service"
];
};
systemd.services = {
snapraid-pre = {
description = "Create btrfs snapshots for each disk in the array";
serviceConfig = {
Type = "oneshot";
ExecStart = "/etc/nixos/scripts/snapraid_snapshots.sh create";
};
path = snapshot-path;
};
snapraid-post = {
description = "Delete btrfs snapshots for each disk in the array";
serviceConfig = {
Type = "oneshot";
ExecStart = "/etc/nixos/scripts/snapraid_snapshots.sh delete";
};
path = snapshot-path;
};
};
2025-06-06 10:18:17 +02:00
services.snapraid = {
enable = true;
scrub.plan = 5;
2025-11-10 14:22:01 +01:00
touchBeforeSync = false; # doesn't work with snapshots
2025-06-06 10:18:17 +02:00
parityFiles = [
"/mnt/drives/43P0A00AFJDH/snapraid1.parity"
2025-11-10 14:22:01 +01:00
"/mnt/drives/ZXA0MNRB/snapraid2.parity"
2025-06-06 10:18:17 +02:00
];
dataDisks = {
2025-11-10 14:22:01 +01:00
d1 = "/mnt/snapshot/ZVV0688G/";
d2 = "/mnt/snapshot/ZVV072JR/";
d3 = "/mnt/snapshot/ZXA0FSKT/";
2025-11-24 10:55:54 +01:00
d4 = "/mnt/snapshot/92F0A079FJDH/";
2025-11-10 14:22:01 +01:00
d5 = "/mnt/snapshot/53G0A2AXFJDH/";
2025-11-24 10:55:54 +01:00
d6 = "/mnt/snapshot/53J0A016FJDH/";
2025-11-10 14:22:01 +01:00
d7 = "/mnt/snapshot/X2N0A0AXFJDH/";
2025-11-24 10:55:54 +01:00
d8 = "/mnt/snapshot/X2N0A0AZFJDH/";
2025-11-10 14:22:01 +01:00
d9 = "/mnt/snapshot/ZA1D9307/";
d10 = "/mnt/snapshot/1EJZN6MZ/";
d11 = "/mnt/snapshot/1EKR513Z/";
d12 = "/mnt/snapshot/1EKVK21Z/";
2024-08-28 00:00:10 +02:00
};
2025-06-06 10:18:17 +02:00
contentFiles = [
"/mnt/snapraid1.content"
"/mnt/drives/43P0A00AFJDH/snapraid2.content"
2025-11-10 14:22:01 +01:00
"/mnt/drives/ZXA0MNRB/snapraid3.content"
2025-06-06 10:18:17 +02:00
];
exclude = excludes;
2024-08-28 00:00:10 +02:00
};
2025-06-06 10:18:17 +02:00
#imports = [ ./modules/snapraid.nix ];
#services.snapraidnew = {
# "8tb" = {
# arrayName = "8tb";
# enable = true;
# scrub.plan = 5;
# parityFiles = [
# "/mnt/drives/ZA1D9307/snapraid-8tb.parity"
# ];
# dataDisks = {
# d1 = "/mnt/drives/1EJZN6MZ";
# d2 = "/mnt/drives/1EKR513Z";
# d3 = "/mnt/drives/1EKVK21Z";
# };
# contentFiles = [
# "/mnt/snapraid-8tb1.content"
# "/mnt/drives/X2N0A0AZFJDH/snapraid-8tb2.content"
# ];
# exclude = excludes;
# };
# "18tb" = {
# enable = true;
# scrub.plan = 5;
# parityFiles = [
# "/mnt/drives/X2N0A0AZFJDH/snapraid.parity"
# ];
# dataDisks = {
# d1 = "/mnt/drives/43P0A00AFJDH";
# d2 = "/mnt/drives/43P0A00FFJDH";
# d3 = "/mnt/drives/92F0A079FJDH";
# d4 = "/mnt/drives/X2N0A0AXFJDH";
# d5 = "/mnt/drives/53J0A016FJDH";
# d6 = "/mnt/drives/ZVV072JR";
# d7 = "/mnt/drives/ZVV0688G";
# };
# contentFiles = [
# "/mnt/snapraid-18tb1.content"
# "/mnt/drives/ZA1D9307/snapraid-18tb2.content"
# ];
# exclude = excludes;
# };
#};
2024-08-28 00:00:10 +02:00
}
# vim: set et ts=2 sw=2 ai: