add borg lock mechanism
This commit is contained in:
parent
5936f7d0a7
commit
8d74aeac0b
1 changed files with 10 additions and 1 deletions
|
|
@ -158,14 +158,23 @@ in
|
||||||
description = "Borg Backup Service";
|
description = "Borg Backup Service";
|
||||||
wants = [ "network-online.target" ];
|
wants = [ "network-online.target" ];
|
||||||
after = [ "network-online.target" ];
|
after = [ "network-online.target" ];
|
||||||
|
|
||||||
# Add borg and required tools to the service's PATH
|
# Add borg and required tools to the service's PATH
|
||||||
path = [ pkgs.borgbackup pkgs.openssh pkgs.curl ];
|
path = [ pkgs.borgbackup pkgs.openssh pkgs.curl ];
|
||||||
|
|
||||||
|
# Prevent concurrent backup runs
|
||||||
|
unitConfig = {
|
||||||
|
ConditionPathExists = "!/var/run/borg-backup.lock";
|
||||||
|
};
|
||||||
|
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
Type = "oneshot";
|
Type = "oneshot";
|
||||||
User = "root"; # Need root to access all backup paths
|
User = "root"; # Need root to access all backup paths
|
||||||
Group = "root";
|
Group = "root";
|
||||||
|
|
||||||
|
# Create lock file on start, remove on stop
|
||||||
|
ExecStartPre = "${pkgs.coreutils}/bin/touch /var/run/borg-backup.lock";
|
||||||
|
ExecStopPost = "${pkgs.coreutils}/bin/rm -f /var/run/borg-backup.lock";
|
||||||
|
|
||||||
# Security settings
|
# Security settings
|
||||||
PrivateTmp = true;
|
PrivateTmp = true;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue