Rework backup node

This commit is contained in:
asonix 2023-07-07 22:07:21 -05:00
parent 9201ea71c4
commit 71eca2ec12
2 changed files with 21 additions and 15 deletions

View file

@ -483,21 +483,21 @@
done
'';
prepareDrives = ''
for drive in "$1" "$2" "$3" "$4"; do
for drive in "$1" "$2"; do
if [ "$drive" == "" ]; then
echo "Must provide 4 drives"
echo "Must provide 2 drives"
exit 1
fi
done
drive_num=1
for drive in "$1" "$2" "$3" "$4"; do
echo "YES" | cryptsetup luksFormat $drive -d ${keyFilePath}
cryptsetup luksOpen $drive "cryptdrive$drive_num" -d ${keyFilePath}
for drive in "$1" "$2"; do
echo "YES" | cryptsetup luksFormat $drive -d ${keyFilePath} --label="DATA$drive_num"
cryptsetup luksOpen "$drive" "cryptdrive$drive_num" -d ${keyFilePath}
drive_num=$((drive_num+1))
done
mkfs.btrfs -L ${deviceLabel} -d raid10 /dev/mapper/cryptdrive1 /dev/mapper/cryptdrive2 /dev/mapper/cryptdrive3 /dev/mapper/cryptdrive4
mkfs.btrfs -L ${deviceLabel} -d raid1 /dev/mapper/cryptdrive1 /dev/mapper/cryptdrive2
mkdir -p ${mountDir}
@ -507,7 +507,7 @@
umount ${mountDir}
for drive_num in {1..4}; do
for drive_num in {1..2}; do
cryptsetup luksClose "cryptdrive$drive_num"
done
'';
@ -526,10 +526,8 @@
environment.etc.crypttab = {
enable = unlockMounts;
text = ''
cryptdrive1 /dev/sda ${keyFilePath} luks
cryptdrive2 /dev/sdb ${keyFilePath} luks
cryptdrive3 /dev/sdc ${keyFilePath} luks
cryptdrive4 /dev/sdd ${keyFilePath} luks
cryptdrive1 /dev/disk/by-label/DATA1 ${keyFilePath} luks
cryptdrive2 /dev/disk/by-label/DATA2 ${keyFilePath} luks
'';
};
@ -539,7 +537,7 @@
"${mountDir}" = {
inherit device;
fsType = "btrfs";
options = [ "defaults" "compress=zstd" "rw" "loop" ];
options = [ "defaults" "compress=zstd" "rw" ];
};
};
in
@ -869,14 +867,22 @@
ip = "192.168.20.129";
name = "k3s10";
}
{
ip = "192.168.20.130";
name = "k3s11";
}
{
ip = "192.168.20.131";
name = "k3s12";
}
]) ++ (builtins.map db [
{
ip = "192.168.20.11";
name = "whitestorm1";
}
{
ip = "192.168.20.24";
name = "redtail2";
ip = "192.168.20.23";
name = "redtail1";
}
]);
};

View file

@ -26,7 +26,7 @@ let
primary = mountDir: subvolumes: {
snapshot_preserve_min = "2d";
snapshot_preserve = "7d 5w";
snapshot_preserve = "2d 1w";
transaction_log = "/var/log/btrbk.log";
volume = { "${mountDir}" = btrbkPrimary { inherit subvolumes; }; };
};