general: modularize borg/rsync config
This commit is contained in:
parent
db0040dcf4
commit
a739323b41
6 changed files with 84 additions and 99 deletions
63
sys/modules/borgsync.nix
Normal file
63
sys/modules/borgsync.nix
Normal file
|
@ -0,0 +1,63 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
cfg = config.local.sys.borgsync;
|
||||
in {
|
||||
options.local.sys.borgsync = {
|
||||
enable = mkEnableOption "borg backup to an rsync.net repo";
|
||||
paths = mkOption {
|
||||
type = with types; nullOr (coercedTo str singleton (listOf str));
|
||||
default = null;
|
||||
description = "Paths to back up.";
|
||||
};
|
||||
exclude = mkOption {
|
||||
type = with types; listOf str;
|
||||
description = "Exclude paths.";
|
||||
default = [];
|
||||
};
|
||||
repoName = mkOption {
|
||||
type = types.str;
|
||||
description = "Remote rsync repository to back up to.";
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
services.borgbackup.jobs.rsync = {
|
||||
paths = cfg.paths;
|
||||
exclude = cfg.exclude;
|
||||
user = "root";
|
||||
group = "root";
|
||||
doInit = true;
|
||||
startAt = [
|
||||
"hourly"
|
||||
];
|
||||
inhibitsSleep = true;
|
||||
persistentTimer = true;
|
||||
|
||||
repo = "zh5777@zh5777.rsync.net:${cfg.repoName}";
|
||||
encryption = {
|
||||
mode = "repokey-blake2";
|
||||
passCommand = "cat /var/trust/borg/${cfg.repoName}_passphrase";
|
||||
};
|
||||
compression = "auto,lz4";
|
||||
prune = {
|
||||
keep = {
|
||||
hourly = 24;
|
||||
daily = 7;
|
||||
weekly = 4;
|
||||
monthly = 12;
|
||||
yearly = 99;
|
||||
};
|
||||
};
|
||||
extraArgs = [
|
||||
"--remote-path=borg14"
|
||||
];
|
||||
};
|
||||
|
||||
environment.sessionVariables.BORG_REMOTE_PATH = "borg14";
|
||||
};
|
||||
}
|
|
@ -16,6 +16,7 @@
|
|||
./net.nix
|
||||
./steam.nix
|
||||
./gtklock.nix
|
||||
./borgsync.nix
|
||||
];
|
||||
|
||||
fonts.packages = with pkgs; [
|
||||
|
|
|
@ -1,49 +0,0 @@
|
|||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
flakes,
|
||||
...
|
||||
}: {
|
||||
services.borgbackup.jobs = {
|
||||
rsync = {
|
||||
paths = [
|
||||
"/home/fabian/nix"
|
||||
"/home/fabian/safe"
|
||||
"/extern/var/media"
|
||||
"/extern/var/fsociety_backup"
|
||||
];
|
||||
exclude = [
|
||||
];
|
||||
user = "root";
|
||||
group = "root";
|
||||
doInit = true;
|
||||
startAt = [
|
||||
"hourly"
|
||||
];
|
||||
inhibitsSleep = true;
|
||||
persistentTimer = true;
|
||||
|
||||
repo = "zh5777@zh5777.rsync.net:posixlycorrect";
|
||||
encryption = {
|
||||
mode = "repokey-blake2";
|
||||
passCommand = "cat /var/trust/borg/posixlycorrect_passphrase";
|
||||
};
|
||||
compression = "auto,lz4";
|
||||
prune = {
|
||||
keep = {
|
||||
hourly = 24;
|
||||
daily = 7;
|
||||
weekly = 4;
|
||||
monthly = 12;
|
||||
yearly = 99;
|
||||
};
|
||||
};
|
||||
extraArgs = [
|
||||
"--remote-path=borg14"
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
environment.sessionVariables.BORG_REMOTE_PATH = "borg14";
|
||||
}
|
|
@ -9,7 +9,6 @@
|
|||
flakes.home-manager.nixosModules.home-manager
|
||||
flakes.impermanence.nixosModule
|
||||
./hardware-configuration.nix
|
||||
./borg.nix
|
||||
];
|
||||
|
||||
local.sys = {
|
||||
|
@ -22,6 +21,16 @@
|
|||
androidSupport.enable = true;
|
||||
steam.enable = true;
|
||||
gtklock.enable = true;
|
||||
borgsync = {
|
||||
enable = true;
|
||||
paths = [
|
||||
"/home/fabian/nix"
|
||||
"/home/fabian/safe"
|
||||
"/extern/var/media"
|
||||
"/extern/var/fsociety_backup"
|
||||
];
|
||||
repoName = "posixlycorrect";
|
||||
};
|
||||
|
||||
users = {
|
||||
fabian = {
|
||||
|
|
|
@ -1,48 +0,0 @@
|
|||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
flakes,
|
||||
...
|
||||
}: {
|
||||
services.borgbackup.jobs = {
|
||||
rsync = {
|
||||
paths = [
|
||||
"/var/lib/forgejo"
|
||||
"/var/lib/mealie"
|
||||
"/var/lib/trilium"
|
||||
];
|
||||
exclude = [
|
||||
];
|
||||
user = "root";
|
||||
group = "root";
|
||||
doInit = true;
|
||||
startAt = [
|
||||
"hourly"
|
||||
];
|
||||
inhibitsSleep = true;
|
||||
persistentTimer = true;
|
||||
|
||||
repo = "zh5777@zh5777.rsync.net:vps";
|
||||
encryption = {
|
||||
mode = "repokey-blake2";
|
||||
passCommand = "cat /var/trust/borg/vps_passphrase";
|
||||
};
|
||||
compression = "auto,lz4";
|
||||
prune = {
|
||||
keep = {
|
||||
hourly = 24;
|
||||
daily = 7;
|
||||
weekly = 4;
|
||||
monthly = 12;
|
||||
yearly = 99;
|
||||
};
|
||||
};
|
||||
extraArgs = [
|
||||
"--remote-path=borg14"
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
environment.sessionVariables.BORG_REMOTE_PATH = "borg14";
|
||||
}
|
|
@ -15,11 +15,20 @@ with lib; {
|
|||
./hardware-configuration.nix
|
||||
./srv
|
||||
./networkMap.nix
|
||||
./borg.nix
|
||||
];
|
||||
|
||||
local.sys = {
|
||||
baseline.enable = true;
|
||||
|
||||
borgsync = {
|
||||
enable = true;
|
||||
paths = [
|
||||
"/var/lib/forgejo"
|
||||
"/var/lib/mealie"
|
||||
"/var/lib/trilium"
|
||||
];
|
||||
repoName = "vps";
|
||||
};
|
||||
|
||||
users.fabian = {
|
||||
enable = true;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue