diff options
| -rw-r--r-- | debian/changelog | 9 | ||||
| -rw-r--r-- | src/Propellor/Property/Obnam.hs | 26 |
2 files changed, 25 insertions, 10 deletions
diff --git a/debian/changelog b/debian/changelog index 729fe42d..a9fa5593 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,12 @@ +propellor (2.15.5) UNRELEASED; urgency=medium + + * Obnam: Only let one backup job run at a time when a host has multiple + different backup properties, to avoid concurrent jobs fighting over + scarce resources (particularly memory). Other jobs block on a lock + file. + + -- Joey Hess <id@joeyh.name> Fri, 19 Feb 2016 11:29:53 -0400 + propellor (2.15.4) unstable; urgency=medium * Build /usr/src/propellor/propellor.git reproducibly, diff --git a/src/Propellor/Property/Obnam.hs b/src/Propellor/Property/Obnam.hs index 92c97f18..666328ac 100644 --- a/src/Propellor/Property/Obnam.hs +++ b/src/Propellor/Property/Obnam.hs @@ -36,6 +36,10 @@ data NumClients = OnlyClient | MultipleClients -- -- Note that this property does not make obnam encrypt the backup -- repository. +-- +-- Since obnam uses a fair amount of system resources, only one obnam +-- backup job will be run at a time. Other jobs will wait their turns to +-- run. backup :: FilePath -> Cron.Times -> [ObnamParam] -> NumClients -> Property NoInfo backup dir crontimes params numclients = backup' dir crontimes params numclients @@ -59,16 +63,18 @@ backup' dir crontimes params numclients = cronjob `describe` desc where desc = dir ++ " backed up by obnam" cronjob = Cron.niceJob ("obnam_backup" ++ dir) crontimes (User "root") "/" $ - unwords $ catMaybes - [ if numclients == OnlyClient - -- forcelock fails if repo does not exist yet - then Just $ forcelockcmd ++ " 2>/dev/null ;" - else Nothing - , Just backupcmd - , if any isKeepParam params - then Just $ "&& " ++ forgetcmd - else Nothing - ] + "flock " ++ shellEscape lockfile ++ " sh -c " ++ shellEscape cmdline + lockfile = "/var/lock/propellor-obnam.lock" + cmdline = unwords $ catMaybes + [ if numclients == OnlyClient + -- forcelock fails if repo does not exist yet + then Just $ forcelockcmd ++ " 2>/dev/null ;" + else Nothing + , Just backupcmd + , if any isKeepParam params + then Just $ "&& " ++ forgetcmd + else Nothing + ] forcelockcmd = unwords $ [ "obnam" , "force-lock" |
