a bit more robust backups; not done yet
This commit is contained in:
parent
b6e854b1c3
commit
f4d306cd7d
@ -5,7 +5,10 @@
|
|||||||
{ config, pkgs, lib, ... }:
|
{ config, pkgs, lib, ... }:
|
||||||
|
|
||||||
let
|
let
|
||||||
snapshot_dirs = [ "/var" "/var/lib" ];
|
snapshot_dirs = {
|
||||||
|
"/var/log" = "rpool/nixos/var/log";
|
||||||
|
"/var/lib" = "rpool/nixos/var/lib";
|
||||||
|
};
|
||||||
ssh_pubkeys = {
|
ssh_pubkeys = {
|
||||||
motiejus = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQC+qpaaD+FCYPcUU1ONbw/ff5j0xXu5DNvp/4qZH/vOYwG13uDdfI5ISYPs8zNaVcFuEDgNxWorVPwDw4p6+1JwRLlhO4J/5tE1w8Gt6C7y76LRWnp0rCdva5vL3xMozxYIWVOAiN131eyirV2FdOaqTwPy4ouNMmBFbibLQwBna89tbFMG/jwR7Cxt1I6UiYOuCXIocI5YUbXlsXoK9gr5yBRoTjl2OfH2itGYHz9xQCswvatmqrnteubAbkb6IUFYz184rnlVntuZLwzM99ezcG4v8/485gWkotTkOgQIrGNKgOA7UNKpQNbrwdPAMugqfSTo6g8fEvy0Q+6OXdxw5X7en2TJE+BLVaXp4pVMdOAzKF0nnssn64sRhsrUtFIjNGmOWBOR2gGokaJcM6x9R72qxucuG5054pSibs32BkPEg6Qzp+Bh77C3vUmC94YLVg6pazHhLroYSP1xQjfOvXyLxXB1s9rwJcO+s4kqmInft2weyhfaFE0Bjcoc+1/dKuQYfPCPSB//4zvktxTXud80zwWzMy91Q4ucRrHTBz3PrhO8ys74aSGnKOiG3ccD3HbaT0Ff4qmtIwHcAjrnNlINAcH/A2mpi0/2xA7T8WpFnvgtkQbcMF0kEKGnNS5ULZXP/LC8BlLXxwPdqTzvKikkTb661j4PhJhinhVwnQ==";
|
motiejus = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQC+qpaaD+FCYPcUU1ONbw/ff5j0xXu5DNvp/4qZH/vOYwG13uDdfI5ISYPs8zNaVcFuEDgNxWorVPwDw4p6+1JwRLlhO4J/5tE1w8Gt6C7y76LRWnp0rCdva5vL3xMozxYIWVOAiN131eyirV2FdOaqTwPy4ouNMmBFbibLQwBna89tbFMG/jwR7Cxt1I6UiYOuCXIocI5YUbXlsXoK9gr5yBRoTjl2OfH2itGYHz9xQCswvatmqrnteubAbkb6IUFYz184rnlVntuZLwzM99ezcG4v8/485gWkotTkOgQIrGNKgOA7UNKpQNbrwdPAMugqfSTo6g8fEvy0Q+6OXdxw5X7en2TJE+BLVaXp4pVMdOAzKF0nnssn64sRhsrUtFIjNGmOWBOR2gGokaJcM6x9R72qxucuG5054pSibs32BkPEg6Qzp+Bh77C3vUmC94YLVg6pazHhLroYSP1xQjfOvXyLxXB1s9rwJcO+s4kqmInft2weyhfaFE0Bjcoc+1/dKuQYfPCPSB//4zvktxTXud80zwWzMy91Q4ucRrHTBz3PrhO8ys74aSGnKOiG3ccD3HbaT0Ff4qmtIwHcAjrnNlINAcH/A2mpi0/2xA7T8WpFnvgtkQbcMF0kEKGnNS5ULZXP/LC8BlLXxwPdqTzvKikkTb661j4PhJhinhVwnQ==";
|
||||||
vno1_root = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMiWb7yeSeuFCMZWarKJD6ZSxIlpEHbU++MfpOIy/2kh";
|
vno1_root = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMiWb7yeSeuFCMZWarKJD6ZSxIlpEHbU++MfpOIy/2kh";
|
||||||
@ -62,7 +65,7 @@ let
|
|||||||
lsof
|
lsof
|
||||||
file
|
file
|
||||||
htop
|
htop
|
||||||
ncdu
|
#ncdu
|
||||||
sqlite
|
sqlite
|
||||||
ripgrep
|
ripgrep
|
||||||
binutils
|
binutils
|
||||||
@ -113,7 +116,7 @@ let
|
|||||||
autoprune = true;
|
autoprune = true;
|
||||||
};
|
};
|
||||||
datasets."rpool/nixos/home".use_template = [ "prod" ];
|
datasets."rpool/nixos/home".use_template = [ "prod" ];
|
||||||
datasets."rpool/nixos/var".use_template = [ "prod" ];
|
datasets."rpool/nixos/var/log".use_template = [ "prod" ];
|
||||||
datasets."rpool/nixos/var/lib".use_template = [ "prod" ];
|
datasets."rpool/nixos/var/lib".use_template = [ "prod" ];
|
||||||
extraArgs = [ "--verbose" ];
|
extraArgs = [ "--verbose" ];
|
||||||
};
|
};
|
||||||
@ -123,27 +126,25 @@ let
|
|||||||
paths = [
|
paths = [
|
||||||
"/var/lib/.snapshot-latest/gitea"
|
"/var/lib/.snapshot-latest/gitea"
|
||||||
"/var/lib/.snapshot-latest/headscale"
|
"/var/lib/.snapshot-latest/headscale"
|
||||||
"/var/.snapshot-latest/log/caddy/access-beta.jakstys.lt.log-*.zst"
|
"/var/log/.snapshot-latest/caddy/access-beta.jakstys.lt.log-*.zst"
|
||||||
];
|
];
|
||||||
repository = "sftp:zh2769@zh2769.rsync.net:hel1-a.servers.jakst";
|
repository = "sftp:zh2769@zh2769.rsync.net:hel1-a.servers.jakst";
|
||||||
initialize = true;
|
initialize = true;
|
||||||
passwordFile = "/var/src/secrets/restic/password";
|
passwordFile = "/var/src/secrets/restic/password";
|
||||||
pruneOpts = [
|
pruneOpts = [
|
||||||
"--keep-daily 7"
|
"--keep-daily 7"
|
||||||
"--keep-weekly 5"
|
|
||||||
];
|
];
|
||||||
backupPrepareCommand = ''
|
backupPrepareCommand = let
|
||||||
set -euo pipefail
|
prepLines = lib.mapAttrsToList (name: value: ''
|
||||||
'' + lib.concatMapStringsSep "\n" (e: ''
|
${pkgs.util-linux}/bin/umount ${name}/.snapshot-latest || : &>/dev/null
|
||||||
${pkgs.util-linux}/bin/umount ${e}/.snapshot-latest || :
|
mkdir -p ${name}/.snapshot-latest
|
||||||
mkdir -p ${e}/.snapshot-latest
|
${pkgs.util-linux}/bin/mount -t zfs $(${pkgs.zfs}/bin/zfs list -H -t snapshot -o name ${value} | sort | tail -1) ${name}/.snapshot-latest
|
||||||
${pkgs.util-linux}/bin/mount -t zfs $(${pkgs.zfs}/bin/zfs list -H -t snapshot -o name ${e} | sort | tail -1) ${e}/.snapshot-latest
|
|
||||||
'') snapshot_dirs;
|
|
||||||
backupCleanupCommand = ''
|
|
||||||
set -euo pipefail
|
|
||||||
'' + lib.concatMapStringsSep "\n" (e: ''
|
|
||||||
${pkgs.util-linux}/bin/umount ${e}/.snapshot-latest
|
|
||||||
'') snapshot_dirs;
|
'') snapshot_dirs;
|
||||||
|
in "set -euo pipefail\n" + lib.concatStringsSep "\n" prepLines;
|
||||||
|
backupCleanupCommand = let
|
||||||
|
cleanupLines = lib.mapAttrsToList (name: value: "${pkgs.util-linux}/bin/umount ${name}/.snapshot-latest") snapshot_dirs;
|
||||||
|
cleanupString = lib.concatStringsSep "\n" cleanupLines;
|
||||||
|
in "set -euo pipefail\n" + cleanupString;
|
||||||
timerConfig = {
|
timerConfig = {
|
||||||
OnCalendar = "00:10";
|
OnCalendar = "00:10";
|
||||||
RandomizedDelaySec = "1h";
|
RandomizedDelaySec = "1h";
|
||||||
@ -281,6 +282,9 @@ let
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# TODO: compress static stuff
|
||||||
|
#${pkgs.findutils}/bin/find ${pkgs.gitea.data} -name '*.css' -exec ${pkgs.brotli}/bin/brotli {} \+
|
||||||
|
|
||||||
networking = {
|
networking = {
|
||||||
hostName = "hel1-a";
|
hostName = "hel1-a";
|
||||||
firewall = {
|
firewall = {
|
||||||
|
Loading…
Reference in New Issue
Block a user