feat: backup client will now only run if there are items to backup.
Closes #54
This commit is contained in:
parent
a42ac52f9d
commit
90d8a105f7
2 changed files with 47 additions and 40 deletions
|
@ -343,6 +343,8 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
config = lib.mkIf cfg.server.enable {
|
config = lib.mkIf cfg.server.enable {
|
||||||
|
# services.skynet_backup.normal.backups = ["/etc/skynet/dns"];
|
||||||
|
|
||||||
# open the firewall for this
|
# open the firewall for this
|
||||||
skynet_firewall.forward = [
|
skynet_firewall.forward = [
|
||||||
"ip daddr ${cfg.server.ip} tcp dport 53 counter packets 0 bytes 0 accept"
|
"ip daddr ${cfg.server.ip} tcp dport 53 counter packets 0 bytes 0 accept"
|
||||||
|
|
|
@ -9,6 +9,8 @@
|
||||||
with lib; let
|
with lib; let
|
||||||
cfg = config.services.skynet_backup;
|
cfg = config.services.skynet_backup;
|
||||||
|
|
||||||
|
enable_client = cfg.normal.backups != null && cfg.normal.backups != [];
|
||||||
|
|
||||||
# since they should all have the same config we can do this
|
# since they should all have the same config we can do this
|
||||||
base = {
|
base = {
|
||||||
paths = cfg.normal.backups;
|
paths = cfg.normal.backups;
|
||||||
|
@ -150,49 +152,52 @@ in {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = {
|
config =
|
||||||
# these values are anabled for every client
|
{
|
||||||
|
# these values are anabled for every client
|
||||||
|
environment.systemPackages = with pkgs; [
|
||||||
|
restic
|
||||||
|
];
|
||||||
|
}
|
||||||
|
// mkIf cfg.server.enable {
|
||||||
|
networking.firewall.allowedTCPPorts = [
|
||||||
|
cfg.server.port
|
||||||
|
];
|
||||||
|
|
||||||
environment.systemPackages = [
|
age.secrets.restic_pw = {
|
||||||
# for flakes
|
file = ../secrets/backup/restic_pw.age;
|
||||||
pkgs.restic
|
path = "${config.services.restic.server.dataDir}/.htpasswd";
|
||||||
];
|
symlink = false;
|
||||||
|
mode = "770";
|
||||||
# A list of all login accounts. To create the password hashes, use
|
owner = "restic";
|
||||||
# nix-shell -p apacheHttpd
|
group = "restic";
|
||||||
# htpasswd -nbB "" "password" | cut -d: -f2
|
|
||||||
|
|
||||||
age.secrets.restic.file = ../secrets/backup/restic.age;
|
|
||||||
|
|
||||||
networking.firewall.allowedTCPPorts = [
|
|
||||||
cfg.server.port
|
|
||||||
];
|
|
||||||
|
|
||||||
services.restic.backups =
|
|
||||||
ownServers
|
|
||||||
// {
|
|
||||||
# merge teh two configs together
|
|
||||||
# backblaze = base // {
|
|
||||||
# # backupos for each server are stored in a folder under their name
|
|
||||||
# repository = "b2:NixOS-Main2:/${cfg.host.name}";
|
|
||||||
# #environmentFile = config.age.secrets.backblaze.path;
|
|
||||||
# };
|
|
||||||
};
|
};
|
||||||
|
|
||||||
age.secrets.restic_pw = mkIf cfg.server.enable {
|
services.restic.server = {
|
||||||
file = ../secrets/backup/restic_pw.age;
|
enable = true;
|
||||||
path = "${config.services.restic.server.dataDir}/.htpasswd";
|
listenAddress = "${cfg.host.ip}:${toString cfg.server.port}";
|
||||||
symlink = false;
|
appendOnly = cfg.server.appendOnly;
|
||||||
mode = "770";
|
privateRepos = true;
|
||||||
owner = "restic";
|
};
|
||||||
group = "restic";
|
}
|
||||||
};
|
// mkIf enable_client {
|
||||||
|
# client stuff here
|
||||||
|
|
||||||
services.restic.server = mkIf cfg.server.enable {
|
# A list of all login accounts. To create the password hashes, use
|
||||||
enable = true;
|
# nix-shell -p apacheHttpd
|
||||||
listenAddress = "${cfg.host.ip}:${toString cfg.server.port}";
|
# htpasswd -nbB "" "password" | cut -d: -f2
|
||||||
appendOnly = cfg.server.appendOnly;
|
|
||||||
privateRepos = true;
|
age.secrets.restic.file = ../secrets/backup/restic.age;
|
||||||
|
|
||||||
|
services.restic.backups =
|
||||||
|
ownServers
|
||||||
|
// {
|
||||||
|
# merge teh two configs together
|
||||||
|
# backblaze = base // {
|
||||||
|
# # backupos for each server are stored in a folder under their name
|
||||||
|
# repository = "b2:NixOS-Main2:/${cfg.host.name}";
|
||||||
|
# #environmentFile = config.age.secrets.backblaze.path;
|
||||||
|
# };
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue