backups int

This commit is contained in:
2025-08-05 14:02:22 +03:00
parent 44a4cbc268
commit 6a62963bf4
2 changed files with 59 additions and 18 deletions
+22
View File
@@ -5,5 +5,27 @@
{ {
services = { services = {
tailscale.enable = config.xlib.device.type != "wsl"; # true, if not wsl tailscale.enable = config.xlib.device.type != "wsl"; # true, if not wsl
systemd = {
services.rsync-archive = lib.mkIf (config.xlib.device.type == "server") {
description = "Backup data using rsync";
after = [ "network.target" ];
requiresMountsFor = [ config.xlib.dirs.archive-drive ];
serviceConfig = {
Type = "oneshot";
#ExecStartPre = "/bin/sh -c 'if ! mountpoint -q ${config.xlib.dirs.archive-drive}; then exit 1; fi'";
ExecStart = "${pkgs.rsync}/bin/rsync -av --delete ${config.xlib.dirs.immich-folder} ${config.xlib.dirs.archive-drive}/Services/immich";
Nice = 19;
IOSchedulingClass = "idle";
};
};
timers.rsync-archive = lib.mkIf (config.xlib.device.type == "server") {
description = "Run rsync backup weekly";
wantedBy = [ "timers.target" ];
timerConfig = {
OnCalendar = "weekly";
Persistent = true;
};
};
};
}; };
} }
+37 -18
View File
@@ -32,79 +32,98 @@
dirs = { dirs = {
user-home = lib.mkOption { user-home = lib.mkOption {
type = lib.types.str; type = lib.types.str;
default = "/home/${config.xlib.device.username}";
description = "User home directory."; description = "User home directory.";
}; };
user-storage = lib.mkOption { user-storage = lib.mkOption {
type = lib.types.str; type = lib.types.str;
default = "${config.xlib.dirs.user-home}/Storage";
description = "User storage directory."; description = "User storage directory.";
}; };
archive-drive = lib.mkOption {
type = lib.types.str;
default = "/mnt/archive";
description = "Archive drive mount point.";
};
therima-drive = lib.mkOption { therima-drive = lib.mkOption {
type = lib.types.str; type = lib.types.str;
default = "/mnt/therima";
description = "Therima drive mount point."; description = "Therima drive mount point.";
}; };
vetymae-drive = lib.mkOption { vetymae-drive = lib.mkOption {
type = lib.types.str; type = lib.types.str;
default = "/mnt/vetymae";
description = "Vetymae drive mount point."; description = "Vetymae drive mount point.";
}; };
wsl-home = lib.mkOption { wsl-home = lib.mkOption {
type = lib.types.str; type = lib.types.str;
default = "/mnt/c/Users/${config.xlib.device.username}";
description = "WSL home directory."; description = "WSL home directory.";
}; };
wsl-storage = lib.mkOption { wsl-storage = lib.mkOption {
type = lib.types.str; type = lib.types.str;
default = "${config.xlib.dirs.wsl-home}/Storage";
description = "WSL storage directory."; description = "WSL storage directory.";
}; };
server-home = lib.mkOption { server-home = lib.mkOption {
type = lib.types.str; type = lib.types.str;
default = "/home/${config.xlib.device.username}/External";
description = "Server home directory."; description = "Server home directory.";
}; };
server-credentials = lib.mkOption { server-credentials = lib.mkOption {
type = lib.types.str; type = lib.types.str;
default = "${config.xlib.dirs.server-home}/Credentials/server";
description = "Server credentials directory."; description = "Server credentials directory.";
}; };
storage = lib.mkOption { storage = lib.mkOption {
type = lib.types.str; type = lib.types.str;
default = "${config.xlib.dirs.server-home}/Storage";
description = "General storage directory."; description = "General storage directory.";
}; };
calibre-library = lib.mkOption { calibre-library = lib.mkOption {
type = lib.types.str; type = lib.types.str;
default = "${config.xlib.dirs.server-home}/Books-Library";
description = "Calibre library directory."; description = "Calibre library directory.";
}; };
music-library = lib.mkOption { music-library = lib.mkOption {
type = lib.types.str; type = lib.types.str;
default = "${config.xlib.dirs.user-home}/Music";
description = "Music library directory."; description = "Music library directory.";
}; };
immich-folder = lib.mkOption { immich-folder = lib.mkOption {
type = lib.types.str; type = lib.types.str;
default = "${config.xlib.dirs.server-home}/Services/immich";
description = "Immich service folder."; description = "Immich service folder.";
}; };
nextcloud-folder = lib.mkOption { nextcloud-folder = lib.mkOption {
type = lib.types.str; type = lib.types.str;
default = "${config.xlib.dirs.server-home}/Services/nextcloud";
description = "Nextcloud service folder."; description = "Nextcloud service folder.";
}; };
postgresql-folder = lib.mkOption { postgresql-folder = lib.mkOption {
type = lib.types.str; type = lib.types.str;
default = "${config.xlib.dirs.server-home}/Services/postgresql";
description = "PostgreSQL service folder."; description = "PostgreSQL service folder.";
}; };
}; };
}; };
}; };
config = { # config = {
xlib.dirs = { # xlib.dirs = {
user-home = "/home/${config.xlib.device.username}"; # user-home = "/home/${config.xlib.device.username}";
user-storage = "${config.xlib.dirs.user-home}/Storage"; # user-storage = "${config.xlib.dirs.user-home}/Storage";
therima-drive = "/mnt/therima"; # therima-drive = "/mnt/therima";
vetymae-drive = "/mnt/vetymae"; # vetymae-drive = "/mnt/vetymae";
wsl-home = "/mnt/c/Users/${config.xlib.device.username}"; # wsl-home = "/mnt/c/Users/${config.xlib.device.username}";
wsl-storage = "${config.xlib.dirs.wsl-home}/Storage"; # wsl-storage = "${config.xlib.dirs.wsl-home}/Storage";
server-home = "/home/${config.xlib.device.username}/External"; # server-home = "/home/${config.xlib.device.username}/External";
server-credentials = "${config.xlib.dirs.server-home}/Credentials/server"; # server-credentials = "${config.xlib.dirs.server-home}/Credentials/server";
storage = "${config.xlib.dirs.server-home}/Storage"; # storage = "${config.xlib.dirs.server-home}/Storage";
calibre-library = "${config.xlib.dirs.server-home}/Books-Library"; # calibre-library = "${config.xlib.dirs.server-home}/Books-Library";
music-library = "${config.xlib.dirs.user-home}/Music"; # music-library = "${config.xlib.dirs.user-home}/Music";
immich-folder = "${config.xlib.dirs.server-home}/Services/immich"; # immich-folder = "${config.xlib.dirs.server-home}/Services/immich";
nextcloud-folder = "${config.xlib.dirs.server-home}/Services/nextcloud"; # nextcloud-folder = "${config.xlib.dirs.server-home}/Services/nextcloud";
postgresql-folder = "${config.xlib.dirs.server-home}/Services/postgresql"; # postgresql-folder = "${config.xlib.dirs.server-home}/Services/postgresql";
}; # };
}; # };
} }