From 4820c7d745a2ddbe7b10f99a079823b92b7edbdd Mon Sep 17 00:00:00 2001 From: oqyude Date: Mon, 18 May 2026 15:11:27 +0300 Subject: [PATCH] systemd units for rsync rewrite --- configurations/server.nix | 5 ++-- modules/server/systemd.nix | 48 ++++++++++++++++++++++++++++++++------ 2 files changed, 44 insertions(+), 9 deletions(-) diff --git a/configurations/server.nix b/configurations/server.nix index ad5a788..0fba112 100644 --- a/configurations/server.nix +++ b/configurations/server.nix @@ -48,7 +48,7 @@ let fsType = "ext4"; }; # Archive drive - "/mnt/archive" = { + "${xlib.dirs.archive-drive}" = { device = "/dev/disk/by-label/archive"; fsType = "exfat"; options = [ @@ -58,7 +58,7 @@ let ]; }; # Mobile SD-Card - "/mnt/mobile" = { + "${xlib.dirs.mobile-drive}" = { device = "/dev/disk/by-uuid/7EB1-DC99"; fsType = "exfat"; options = [ @@ -67,6 +67,7 @@ let "gid=1000" ]; }; + # Services in /mnt folder "${xlib.dirs.services-mnt-folder}" = { device = "${xlib.dirs.services-folder}"; fsType = "none"; diff --git a/modules/server/systemd.nix b/modules/server/systemd.nix index 6301250..65552d6 100644 --- a/modules/server/systemd.nix +++ b/modules/server/systemd.nix @@ -11,31 +11,65 @@ rsync-archivesta = { # Archivesta description = "Backup data using rsync"; - requisite = [ "mnt-archive.mount" ]; # hard-code + # wants = [ + # "mnt-archive.mount" + # ]; + # requires = [ + # "mnt-archive.mount" + # ]; + # after = [ + # "mnt-archive.mount" + # ]; + unitConfig.RequiresMountsFor = [ + "${xlib.dirs.archive-drive}" + "${xlib.dirs.server-home}" + "${xlib.dirs.services-mnt-folder}" + ]; script = '' - ${pkgs.rsync}/bin/rsync -rtv --delete ${xlib.dirs.services-folder}/ ${xlib.dirs.archive-drive}/Services/ + ${pkgs.rsync}/bin/rsync -rtv --delete \ + ${xlib.dirs.services-mnt-folder}/ \ + ${xlib.dirs.archive-drive}/Services/ ''; serviceConfig = { Type = "oneshot"; User = "root"; Group = "root"; - Nice = 19; + Nice = 10; + CPUQuota = "5%"; IOSchedulingClass = "idle"; }; }; rsync-archivesta-lite = { # Archivesta Lite description = "Backup data using rsync"; - requisite = [ "mnt-mobile.mount" ]; # hard-code + # wants = [ + # "mnt-mobile.mount" + # ]; + # after = [ + # "mnt-mobile.mount" + # ]; + # requires = [ + # "mnt-mobile.mount" + # ]; + unitConfig.RequiresMountsFor = [ + "${xlib.dirs.server-home}" + "${xlib.dirs.mobile-drive}" + ]; script = '' - ${pkgs.rsync}/bin/rsync -rtv --delete ${xlib.dirs.server-home}/Music/ ${xlib.dirs.mobile-drive}/Music/ - ${pkgs.rsync}/bin/rsync -rtv --delete "${xlib.dirs.server-home}/Hosts/epral/Neo Backup/" "${xlib.dirs.mobile-drive}/Neo Backup/" + ${pkgs.rsync}/bin/rsync -rtv --delete \ + ${xlib.dirs.server-home}/Music/ \ + ${xlib.dirs.mobile-drive}/Music/ + + ${pkgs.rsync}/bin/rsync -rtv --delete \ + "${xlib.dirs.server-home}/Hosts/epral/Neo Backup/" \ + "${xlib.dirs.mobile-drive}/Neo Backup/" ''; serviceConfig = { Type = "oneshot"; User = "root"; Group = "root"; - Nice = 19; + Nice = 10; + CPUQuota = "5%"; IOSchedulingClass = "idle"; }; };