WIP: Add locking of borgmatic config file #254
|
@ -3,6 +3,7 @@ import json
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
import fcntl
|
||||||
from subprocess import CalledProcessError
|
from subprocess import CalledProcessError
|
||||||
|
|
||||||
import colorama
|
import colorama
|
||||||
|
@ -575,7 +576,7 @@ def main(): # pragma: no cover
|
||||||
fcntl.flock(f.fileno(), fcntl.LOCK_EX | fcntl.LOCK_NB)
|
fcntl.flock(f.fileno(), fcntl.LOCK_EX | fcntl.LOCK_NB)
|
||||||
except IOError:
|
except IOError:
|
||||||
logger.critical("Failed to acquire lock for {}".format(config_filename))
|
logger.critical("Failed to acquire lock for {}".format(config_filename))
|
||||||
sys.exit(0))
|
sys.exit(0)
|
||||||
locks.append(f)
|
locks.append(f)
|
||||||
|
|
||||||
summary_logs = parse_logs + list(collect_configuration_run_summary_logs(configs, arguments))
|
summary_logs = parse_logs + list(collect_configuration_run_summary_logs(configs, arguments))
|
||||||
|
|
|
@ -32,6 +32,10 @@ map:
|
||||||
type: bool
|
type: bool
|
||||||
desc: Stay in same file system (do not cross mount points). Defaults to false.
|
desc: Stay in same file system (do not cross mount points). Defaults to false.
|
||||||
example: true
|
example: true
|
||||||
|
lock_config:
|
||||||
|
type: bool
|
||||||
|
desc: Lock config when running borgmatic to prevent multiple instances from running simultaneously
|
||||||
|
example: true
|
||||||
|
|||||||
numeric_owner:
|
numeric_owner:
|
||||||
type: bool
|
type: bool
|
||||||
desc: Only store/extract numeric user and group identifiers. Defaults to false.
|
desc: Only store/extract numeric user and group identifiers. Defaults to false.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user
The fact that it's locking the configuration file might just be an implementation detail as far as the user is concerned. What about calling this something like
lock_client
,lock_borgmatic
, etc? I don't feel strongly about this in any case.Those sound better. I’ll fix it when I get the chance
I renamed it to
lock_client
and left it as a bool for now. I didn't see immediately the best way to do it with the config (and validation), but if you want to keep options open switching this to something likelock: "config"
so that then you could add alock: "everything
option later would be an option.I also wasn't sure if the example line is supposed to be the default value or not.
A bool is fine for now, as far as I'm concerned.
example:
is not usually the default value. In fact it's often the opposite of the default value in that it's demonstrating how you would override the default if you are so inclined. Soexample: true
sounds right to me here, given that I'm assuming the default isfalse
(don't lock).