sj-srv1: init with restic backup
This commit is contained in:
parent
26f0bde4b3
commit
2c84e79f4a
12 changed files with 380 additions and 34 deletions
125
nix/os/devices/sj-srv1/system.nix
Normal file
125
nix/os/devices/sj-srv1/system.nix
Normal file
|
@ -0,0 +1,125 @@
|
|||
{ pkgs
|
||||
, lib
|
||||
, config
|
||||
, repoFlake
|
||||
, nodeName
|
||||
, ...
|
||||
}:
|
||||
|
||||
{
|
||||
imports = [
|
||||
../../snippets/systemd-resolved.nix
|
||||
];
|
||||
|
||||
networking.firewall.enable = true;
|
||||
networking.nftables.enable = true;
|
||||
|
||||
networking.firewall.allowedTCPPorts = [
|
||||
# iperf3
|
||||
5201
|
||||
];
|
||||
|
||||
networking.firewall.logRefusedConnections = false;
|
||||
|
||||
networking.usePredictableInterfaceNames = false;
|
||||
|
||||
networking.useNetworkd = true;
|
||||
networking.useDHCP = true;
|
||||
|
||||
networking.nat = {
|
||||
enable = true;
|
||||
internalInterfaces = [ "ve-*" ];
|
||||
externalInterface = "eth0";
|
||||
};
|
||||
|
||||
# virtualization
|
||||
virtualisation = { docker.enable = false; };
|
||||
|
||||
nix.gc = { automatic = true; };
|
||||
|
||||
sops.secrets.restic-password.sopsFile = ../../../../secrets/${nodeName}/secrets.yaml;
|
||||
|
||||
# adapted from https://github.com/lilyinstarlight/foosteros/blob/5c75ded111878970fd4f600c7adc013f971d5e71/config/restic.nix
|
||||
services.restic.backups.${nodeName} =
|
||||
let
|
||||
btrfs = "${pkgs.btrfs-progs}/bin/btrfs";
|
||||
in
|
||||
{
|
||||
initialize = true;
|
||||
repository = "sftp://u217879-sub3@u217879-sub3.your-storagebox.de:23/restic/${nodeName}";
|
||||
|
||||
paths = [
|
||||
"/backup"
|
||||
];
|
||||
|
||||
pruneOpts = [
|
||||
"--keep-daily 7"
|
||||
"--keep-weekly 5"
|
||||
"--keep-monthly 12"
|
||||
"--keep-yearly 2"
|
||||
];
|
||||
|
||||
timerConfig = {
|
||||
OnCalendar = lib.mkDefault "daily";
|
||||
Persistent = true;
|
||||
};
|
||||
|
||||
passwordFile = config.sops.secrets.restic-password.path;
|
||||
|
||||
backupPrepareCommand = ''
|
||||
${btrfs} su snapshot -r /var/lib/container-volumes /backup/container-volumes
|
||||
'';
|
||||
backupCleanupCommand = ''
|
||||
${btrfs} su delete /backup/container-volumes
|
||||
'';
|
||||
};
|
||||
|
||||
containers = {
|
||||
mailserver = import ../../containers/mailserver.nix {
|
||||
inherit repoFlake;
|
||||
|
||||
autoStart = true;
|
||||
|
||||
hostAddress = "192.168.100.10";
|
||||
localAddress = "192.168.100.11";
|
||||
|
||||
imapsPort = 993;
|
||||
sievePort = 4190;
|
||||
};
|
||||
|
||||
webserver =
|
||||
import ../../containers/webserver.nix
|
||||
{
|
||||
inherit repoFlake;
|
||||
|
||||
autoStart = true;
|
||||
|
||||
hostAddress = "192.168.100.12";
|
||||
localAddress = "192.168.100.13";
|
||||
|
||||
httpPort = 80;
|
||||
httpsPort = 443;
|
||||
};
|
||||
|
||||
syncthing = import ../../containers/syncthing.nix {
|
||||
autoStart = true;
|
||||
|
||||
hostAddress = "192.168.100.14";
|
||||
localAddress = "192.168.100.15";
|
||||
|
||||
syncthingPort = 22000;
|
||||
};
|
||||
};
|
||||
|
||||
home-manager.users.steveej = import ../../../home-manager/configuration/text-minimal.nix {
|
||||
inherit pkgs;
|
||||
};
|
||||
|
||||
# This value determines the NixOS release from which the default
|
||||
# settings for stateful data, like file locations and database versions
|
||||
# on your system were taken. It‘s perfectly fine and recommended to leave
|
||||
# this value at the release version of the first install of this system.
|
||||
# Before changing this value read the documentation for this option
|
||||
# (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
|
||||
system.stateVersion = "22.11"; # Did you read the comment?
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue