feat(servers): setup borgmatic for auto backups
All checks were successful
Discord / discord commits (push) Successful in 1m13s

This commit is contained in:
matt1432 2023-12-27 00:33:19 -05:00
parent a454167053
commit e3300dcac3
4 changed files with 116 additions and 66 deletions

View file

@ -6,6 +6,7 @@
../../modules/tailscale.nix ../../modules/tailscale.nix
./modules/binary-cache.nix ./modules/binary-cache.nix
./modules/borgmatic.nix
./modules/minecraft.nix ./modules/minecraft.nix
]; ];

View file

@ -0,0 +1,32 @@
{
config,
lib,
pkgs,
...
}: {
# Make this file declare default settings
options.services.borgmatic = with lib; {
defaults = mkOption {
type = types.attrs;
};
};
# Make sure known_hosts has the needed info
config = {
services.borgmatic = {
enable = true;
defaults = {
keep_daily = 7;
# FIXME: doesn't work, have to put it in /root/.ssh
ssh_command = "ssh -i /root/.ssh/borg";
encryption_passcommand = "${pkgs.coreutils}/bin/cat ${config.sops.secrets.borg-repo.path}";
source_directories_must_exist = true;
borgmatic_source_directory = "/tmp/borgmatic";
store_config_files = false;
};
};
};
}

View file

@ -6,85 +6,102 @@
}: { }: {
imports = [nms.nixosModules.default]; imports = [nms.nixosModules.default];
services.modded-minecraft-servers = { services = {
eula = true; modded-minecraft-servers = {
user = config.vars.user; eula = true;
group = "users"; user = config.vars.user;
group = "users";
instances = let instances = let
jre8 = pkgs.temurin-bin-8; jre8 = pkgs.temurin-bin-8;
jre17 = pkgs.temurin-bin-17; jre17 = pkgs.temurin-bin-17;
defaults = { defaults = {
spawn-protection = 0; spawn-protection = 0;
max-tick-time = 5 * 60 * 1000; max-tick-time = 5 * 60 * 1000;
allow-flight = true; allow-flight = true;
}; };
in { in {
# Vanilla Survival # Vanilla Survival
sv = { sv = {
enable = false; enable = false;
serverConfig = serverConfig =
{ {
server-port = 25569; server-port = 25569;
extra-options = { extra-options = {
}; };
} }
// defaults; // defaults;
}; };
# Vanilla Creative # Vanilla Creative
cv = { cv = {
enable = true; enable = true;
jvmMaxAllocation = "6G"; jvmMaxAllocation = "6G";
jvmInitialAllocation = "2G"; jvmInitialAllocation = "2G";
jvmPackage = jre17; jvmPackage = jre17;
jvmOpts = ""; jvmOpts = "";
serverConfig = serverConfig =
{ {
server-port = 25566; server-port = 25566;
motd = "creative mode gaming"; motd = "creative mode gaming";
extra-options = { extra-options = {
difficulty = "hard"; difficulty = "hard";
enable-command-block = true; enable-command-block = true;
enforce-whitelist = true; enforce-whitelist = true;
gamemode = "creative"; gamemode = "creative";
max-players = 6; max-players = 6;
view-distance = 16; view-distance = 16;
}; };
} }
// defaults; // defaults;
}; };
# Modded https://www.curseforge.com/minecraft/modpacks/nomi-ceu # Modded https://www.curseforge.com/minecraft/modpacks/nomi-ceu
nomi = { nomi = {
enable = true; enable = false;
jvmMaxAllocation = "10G"; jvmMaxAllocation = "10G";
jvmInitialAllocation = "2G"; jvmInitialAllocation = "2G";
jvmPackage = jre8; jvmPackage = jre8;
jvmOpts = ""; jvmOpts = "";
serverConfig = serverConfig =
{ {
server-port = 25569; server-port = 25569;
motd = "Nomi CEu Server, v1.7-alpha-2"; motd = "Nomi CEu Server, v1.7-alpha-2";
extra-options = { extra-options = {
max-players = 8; max-players = 8;
difficulty = 1; difficulty = 1;
view-distance = 10; view-distance = 10;
simulation-distance = 10; simulation-distance = 10;
level-type = "lostcities"; level-type = "lostcities";
}; };
} }
// defaults; // defaults;
};
}; };
}; };
borgmatic.configurations.mc =
config.services.borgmatic.defaults
// {
source_directories = [
"/var/lib/minecraft"
];
repositories = [
{
label = "PVE";
path = "ssh://matt@pve/data/backups/borg";
}
];
};
}; };
} }

Binary file not shown.