made snapraid use snapshots
This commit is contained in:
parent
522ed5da99
commit
44d649c555
1 changed files with 141 additions and 0 deletions
141
snapraid.nix
Normal file
141
snapraid.nix
Normal file
|
|
@ -0,0 +1,141 @@
|
|||
{ pkgs, ... }:
|
||||
let
|
||||
excludes = [
|
||||
"/media/usenet/incomplete/"
|
||||
"/.snapshot/"
|
||||
];
|
||||
snapshot-path = [
|
||||
pkgs.bash
|
||||
pkgs.btrfs-progs
|
||||
];
|
||||
in
|
||||
{
|
||||
#systemd.timers."snapraid-sync".enable = false; #temporarily
|
||||
#systemd.timers."snapraid-scrub".enable = false; #temporarily
|
||||
|
||||
systemd.services."snapraid-sync" = {
|
||||
#preStart = "systemctl start snapraid-pre";
|
||||
#postStart = "systemctl start snapraid-post";
|
||||
#path = [
|
||||
# pkgs.bash
|
||||
# pkgs.btrfs-progs
|
||||
#];
|
||||
serviceConfig = {
|
||||
ReadWritePaths = [
|
||||
"/mnt/snapshot/ZVV0688G/.snapshot/"
|
||||
"/mnt/snapshot/ZVV072JR/.snapshot/"
|
||||
"/mnt/snapshot/ZXA0FSKT/.snapshot/"
|
||||
"/mnt/snapshot/X2N0A0AZFJDH/.snapshot/"
|
||||
"/mnt/snapshot/53G0A2AXFJDH/.snapshot/"
|
||||
"/mnt/snapshot/92F0A079FJDH/.snapshot/"
|
||||
"/mnt/snapshot/X2N0A0AXFJDH/.snapshot/"
|
||||
"/mnt/snapshot/43P0A00FFJDH/.snapshot/"
|
||||
"/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/modules/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/modules/snapraid_snapshots.sh delete";
|
||||
};
|
||||
path = snapshot-path;
|
||||
};
|
||||
};
|
||||
|
||||
services.snapraid = {
|
||||
enable = true;
|
||||
scrub.plan = 5;
|
||||
touchBeforeSync = false; # doesn't work with snapshots
|
||||
parityFiles = [
|
||||
"/mnt/drives/43P0A00AFJDH/snapraid1.parity"
|
||||
"/mnt/drives/ZXA0MNRB/snapraid2.parity"
|
||||
];
|
||||
dataDisks = {
|
||||
d1 = "/mnt/snapshot/ZVV0688G/";
|
||||
d2 = "/mnt/snapshot/ZVV072JR/";
|
||||
d3 = "/mnt/snapshot/ZXA0FSKT/";
|
||||
d4 = "/mnt/snapshot/X2N0A0AZFJDH/";
|
||||
d5 = "/mnt/snapshot/53G0A2AXFJDH/";
|
||||
d6 = "/mnt/snapshot/92F0A079FJDH/";
|
||||
d7 = "/mnt/snapshot/X2N0A0AXFJDH/";
|
||||
d8 = "/mnt/snapshot/43P0A00FFJDH/";
|
||||
d9 = "/mnt/snapshot/ZA1D9307/";
|
||||
d10 = "/mnt/snapshot/1EJZN6MZ/";
|
||||
d11 = "/mnt/snapshot/1EKR513Z/";
|
||||
d12 = "/mnt/snapshot/1EKVK21Z/";
|
||||
};
|
||||
contentFiles = [
|
||||
"/mnt/snapraid1.content"
|
||||
"/mnt/drives/43P0A00AFJDH/snapraid2.content"
|
||||
"/mnt/drives/ZXA0MNRB/snapraid3.content"
|
||||
];
|
||||
exclude = excludes;
|
||||
};
|
||||
|
||||
#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;
|
||||
# };
|
||||
#};
|
||||
|
||||
}
|
||||
# vim: set et ts=2 sw=2 ai:
|
||||
Loading…
Add table
Reference in a new issue