···
+
(mapAttrs' (name: cfg: nameValuePair "tarsnap-${name}" {
description = "Tarsnap archive '${name}'";
requires = [ "network-online.target" ];
after = [ "network-online.target" ];
···
CapabilityBoundingSet = [ "CAP_DAC_READ_SEARCH" ];
PermissionsStartOnly = "true";
+
(mapAttrs' (name: cfg: nameValuePair "tarsnap-restore-${name}"{
+
description = "Tarsnap restore '${name}'";
+
requires = [ "network-online.target" ];
+
path = [ pkgs.iputils pkgs.tarsnap pkgs.utillinux ];
+
while ! ping -q -c 1 v1-0-0-server.tarsnap.com &> /dev/null; do sleep 3; done
+
tarsnap = ''tarsnap --configfile "/etc/tarsnap/${name}.conf"'';
+
lastArchive = ''$(${tarsnap} --list-archives | sort | tail -1)'';
+
run = ''${tarsnap} -x -f "${lastArchive}" ${optionalString cfg.verbose "-v"}'';
+
in if (cfg.cachedir != null) then ''
+
mkdir -p ${cfg.cachedir}
+
chmod 0700 ${cfg.cachedir}
+
if [ ! -e ${cfg.cachedir}/firstrun ]; then
+
) 10>${cfg.cachedir}/firstrun
+
) 9>${cfg.cachedir}/lockf
+
exec flock ${cfg.cachedir}/firstrun ${run}
+
IOSchedulingClass = "idle";
+
NoNewPrivileges = "true";
+
CapabilityBoundingSet = [ "CAP_DAC_READ_SEARCH" ];
+
PermissionsStartOnly = "true";
# Note: the timer must be Persistent=true, so that systemd will start it even
# if e.g. your laptop was asleep while the latest interval occurred.