feat: zfs auto snapshotting
This commit is contained in:
parent
dd60b94a59
commit
8f55b769fe
|
@ -57,6 +57,63 @@
|
|||
};
|
||||
};
|
||||
|
||||
services.zrepl = {
|
||||
enable = true;
|
||||
settings = {
|
||||
global = {
|
||||
logging = [
|
||||
{
|
||||
type = "syslog";
|
||||
level = "info";
|
||||
format = "human";
|
||||
}
|
||||
];
|
||||
# TODO Monitoring
|
||||
};
|
||||
jobs = [
|
||||
#{
|
||||
# type = "push";
|
||||
# name = "push-to-remote";
|
||||
#}
|
||||
{
|
||||
type = "snap";
|
||||
name = "mach-schnipp-schusss";
|
||||
filesystems = {
|
||||
"panzer/local/state<" = true;
|
||||
"panzer/safe<" = true;
|
||||
"rpool/local/state<" = true;
|
||||
"rpool/safe<" = true;
|
||||
};
|
||||
snapshotting = {
|
||||
type = "periodic";
|
||||
prefix = "zrepl-";
|
||||
interval = "10m";
|
||||
timestamp_format = "iso-8601";
|
||||
};
|
||||
pruning = {
|
||||
keep = [
|
||||
{
|
||||
type = "regex";
|
||||
regex = "^zrepl-.*$";
|
||||
negate = true;
|
||||
}
|
||||
{
|
||||
type = "grid";
|
||||
grid = lib.concatStringsSep " | " [
|
||||
"1x1d(keep=all)"
|
||||
"142x1h(keep=2)"
|
||||
"90x1d(keep=2)"
|
||||
"500x7d"
|
||||
];
|
||||
regex = "^zrepl-.*$";
|
||||
}
|
||||
];
|
||||
};
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
fileSystems."/state".neededForBoot = true;
|
||||
fileSystems."/panzer/state".neededForBoot = true;
|
||||
fileSystems."/panzer/persist".neededForBoot = true;
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
"01-lan1" = {
|
||||
address = ["192.168.178.32/24"];
|
||||
gateway = ["192.168.178.1"];
|
||||
matchConfig.MACAddress = config.secrets.secrets.local.networking.lan01.mac;
|
||||
matchConfig.MACAddress = config.secrets.secrets.local.networking.interfaces.lan01.mac;
|
||||
dns = ["192.168.178.2"];
|
||||
networkConfig = {
|
||||
IPv6PrivacyExtensions = "yes";
|
||||
|
|
|
@ -1,18 +1,13 @@
|
|||
age-encryption.org/v1
|
||||
-> X25519 yvfsxGyyzm6ltKrzJCvt4fiNKq28qKc1NhJAfsBoKHk
|
||||
ccIcrFkuQ1OSXKQQD/6gUoM9Rmgxu1ZAmIyMVHgt4eM
|
||||
-> piv-p256 XTQkUA A4vKRNyh9FMXQLR38Qr5BNRa9QunSvkwjf6lIgYbgnuO
|
||||
LaaIJYLwQcIS9/rXWF8+8hjQ0POPOQntD/hq2w0Dn7I
|
||||
-> piv-p256 ZFgiIw Avd6vl3zndUJ3sjF0LCOEWDIr7Kw+meAlhI96x5fblgC
|
||||
+oMYDzKBntsA5DJmLQpnVPemq1yK++j0ralMOiqgAps
|
||||
-> piv-p256 ZFgiIw AkFE4lLts1uL8TM3DEIlPXJh7G4na8AVXm/AYdnBs8x3
|
||||
RWV+VTPrJ+pGG9Zlok7J71Wb4r6yFqbN/fPYPBCdzxs
|
||||
-> s?N`-grease
|
||||
rN+B4f0cPFjxtUR/20RrSnzpacxc6SR3d4yiIaNB6iFH2mH01HlFcjFN46nwVs1g
|
||||
CWafTVncI4Vne/C+cA
|
||||
--- DDayA/fH/5rwjIYpl6JLltwh8+4EWcKYQ4P+pTkNuxI
|
||||
ûïc™Ä=¤ÀVðsS†s{@I=Kˆ4È}_{…\Álž´@„h&F$” ;(®ŠB
|
||||
¾šŸ.ÄÌDvZÁ¾?;¾Ê]Oïkƒ~Ló¨NxÕÅûK…·FpØ)0eº+Î<>k;¶õÒu
|
||||
<0E>>ãÁÄéO,92B<*fá
|
||||
K|ÒšAàvñ@8_òu~ö<>ÿŽâ¹L‘)÷·†^µÌ¥É›vººtY«Ù:5*<16> ã{^X´oí<6F>òè¥
|
||||
2èÐZ ,B+zkæS$“ƒ˜^4Nª®É(Txáøe<1D>°{#Õ8Ä·p6`âr–& RÀÔðT pSFz"ˆÁÈfŠñ)È£ÍÀo=¯SÉx^³“; ôâ¨R•
|
||||
-> X25519 peN8LddAbhPxA8gKX8PUl5rsPQ8bLGu3pfsMYrm0cVE
|
||||
p9TRJH5BkYALKWathegKIV0ohIbI0QZ660V8awsFOis
|
||||
-> piv-p256 XTQkUA A+UjNTuqedCWHXhFamoMtkFmOT8xUY6U/0X8EqBGZaXf
|
||||
G9HFGv2ZkKXy8vldhA6VYUvU8Yws9dWvqt+9VR3zIrs
|
||||
-> piv-p256 ZFgiIw AtHwhB/pCVKkW1n9pgcAOkcNOAezpYDgag+S/NBqF61u
|
||||
WCV3rZkXdXqfwJsbSC9zM/zVa3TUstgBBcAGmG7UccM
|
||||
-> piv-p256 ZFgiIw A01o+NKTlNvjyraiG1FQeJ2S+S8cmbFs2Tt/B6yXcYra
|
||||
gFUdee9s1/111+FoHQ+zsGwkYuEMXvCsjpgOyc3FRFg
|
||||
-> uu4VaK0-grease u\p]JK D\k37zk
|
||||
dg
|
||||
--- cyNvJMdMwm9HQ9yKMVctRQN7lxiupua6/WY/oAjX8zE
|
||||
8£<EFBFBD>•¯p”ÙøÕ’‰ßKÌgäPpÚéHÀDdд/Ì_Yus7î«ØÒe:aJ˪¥”ë@†‹³s‰Ð`à²A<¸“ó'"'úfê)3(‹Éôów#7¸¾DEZÔ
êÍÊÞŸ*’c‚Q¿†È‚óÁÇùèÀ“3ûö;_<>Pø<06>ÓzŠù3.¨zn%ZÌ<5A>2
ôÐnMñ1JDe.¦Òâ{5öÎ<C3B6>7|¶‰»GvXY)xî7R›ß8Ÿ“š3PýP‰ærã—.c£fÒ‘CF@ÊCISÐÃŒJ~U×›†Ú!ÜøÅô<C385>$¹H—áMÜYO²•¨LPܱþ,t‡ê •KìGÊfŸõ½©ÝC’Í9º›šÙ¸C
„îÂiB6Í*›šjf
|
|
@ -5,16 +5,17 @@ _inputs: _self: super: {
|
|||
containers.mkConfig = name: config:
|
||||
super.lib.mkMerge [
|
||||
{
|
||||
bindmounts = {
|
||||
bindMounts = {
|
||||
"state" = {
|
||||
mountpoint = "/state";
|
||||
mountPoint = "/state";
|
||||
hostPath = "/state/containers/${name}";
|
||||
};
|
||||
"persist" = {
|
||||
mountpoint = "/persist";
|
||||
hostPath = config.zfs.mountpoint;
|
||||
mountPoint = "/persist";
|
||||
hostPath = "/containers/${name}";
|
||||
};
|
||||
};
|
||||
zfs.mountpoint = super.lib.mkDefault "/containers/${name}";
|
||||
#config = {...}: {
|
||||
#};
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
inputs: [
|
||||
(import ./disko.nix inputs)
|
||||
(import ./containers.nix inputs)
|
||||
(import ./misc.nix inputs)
|
||||
]
|
||||
|
|
29
lib/misc.nix
Normal file
29
lib/misc.nix
Normal file
|
@ -0,0 +1,29 @@
|
|||
_inputs: _self: super: let
|
||||
inherit
|
||||
(super.lib)
|
||||
unique
|
||||
foldl'
|
||||
filter
|
||||
;
|
||||
|
||||
# Counts how often each element occurrs in xs.
|
||||
# Elements must be strings.
|
||||
countOccurrences =
|
||||
foldl'
|
||||
(acc: x: acc // {${x} = (acc.${x} or 0) + 1;})
|
||||
{};
|
||||
# Returns all elements in xs that occur at least twice
|
||||
duplicates = xs: let
|
||||
occurrences = countOccurrences xs;
|
||||
in
|
||||
unique (filter (x: occurrences.${x} > 1) xs);
|
||||
in {
|
||||
lib =
|
||||
super.lib
|
||||
// {
|
||||
inherit
|
||||
countOccurrences
|
||||
duplicates
|
||||
;
|
||||
};
|
||||
}
|
|
@ -40,7 +40,6 @@ in {
|
|||
|
||||
mountpoint = mkOption {
|
||||
type = types.str;
|
||||
default = "/containers/${name}";
|
||||
description = mdDoc "The host's mountpoint for the containers dataset";
|
||||
};
|
||||
};
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
...
|
||||
}: {
|
||||
imports = [./containers.nix];
|
||||
containers.nextcloud = lib.container.mkConfig "nextcloud" {
|
||||
containers.nextcloud = lib.containers.mkConfig "nextcloud" {
|
||||
autoStart = true;
|
||||
zfs = {
|
||||
enable = true;
|
||||
|
|
Loading…
Reference in a new issue