diff options
| author | Joey Hess <joeyh@joeyh.name> | 2016-02-24 17:12:43 -0400 |
|---|---|---|
| committer | Joey Hess <joeyh@joeyh.name> | 2016-02-24 17:12:43 -0400 |
| commit | c716d1a0d4b18737b133ba9cc23c97388f72f5c0 (patch) | |
| tree | 7be06dd25e433685d921c8ce344bd5f9d2cb03d2 /src/Propellor/Property/Obnam.hs | |
| parent | a2323b58c2edba99f06d7810b95da05aecb20b5f (diff) | |
| parent | 90219e30615e09779469ceae272cf41943d43585 (diff) | |
Merge branch 'joeyconfig'
Diffstat (limited to 'src/Propellor/Property/Obnam.hs')
| -rw-r--r-- | src/Propellor/Property/Obnam.hs | 26 |
1 files changed, 16 insertions, 10 deletions
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" |
