summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--debian/changelog2
-rw-r--r--src/Propellor/Property/Attic.hs10
2 files changed, 8 insertions, 4 deletions
diff --git a/debian/changelog b/debian/changelog
index 3c3d41ac..ef68886a 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -5,6 +5,8 @@ propellor (3.0.2) UNRELEASED; urgency=medium
* Apt.unattendedUpgrades: Enable mailing problems reports to root.
Thanks, Félix Sipma.
* Added Propellor.Property.Fstab, and moved the fstabbed property to there.
+ * Attic module added for the backup system.
+ Thanks, Félix Sipma.
-- Joey Hess <id@joeyh.name> Tue, 05 Apr 2016 13:48:47 -0400
diff --git a/src/Propellor/Property/Attic.hs b/src/Propellor/Property/Attic.hs
index 3d857913..0fadc113 100644
--- a/src/Propellor/Property/Attic.hs
+++ b/src/Propellor/Property/Attic.hs
@@ -17,13 +17,15 @@ import Data.List (intercalate)
type AtticParam = String
+type AtticRepo = FilePath
+
installed :: Property DebianLike
installed = Apt.installed ["attic"]
-repoExists :: FilePath -> IO Bool
+repoExists :: AtticRepo -> IO Bool
repoExists repo = boolSystem "attic" [Param "list", File repo]
-init :: FilePath -> Property DebianLike
+init :: AtticRepo -> Property DebianLike
init backupdir = check (not <$> repoExists backupdir) (cmdProperty "attic" initargs)
`requires` installed
where
@@ -32,7 +34,7 @@ init backupdir = check (not <$> repoExists backupdir) (cmdProperty "attic" inita
, backupdir
]
-restored :: [FilePath] -> FilePath -> Property DebianLike
+restored :: [FilePath] -> AtticRepo -> Property DebianLike
restored dirs backupdir = cmdProperty "attic" restoreargs
`assume` MadeChange
`describe` ("attic restore from " ++ backupdir)
@@ -44,7 +46,7 @@ restored dirs backupdir = cmdProperty "attic" restoreargs
]
++ dirs
-backup :: [FilePath] -> FilePath -> Cron.Times -> [AtticParam] -> [KeepPolicy] -> Property DebianLike
+backup :: [FilePath] -> AtticRepo -> Cron.Times -> [AtticParam] -> [KeepPolicy] -> Property DebianLike
backup dirs backupdir crontimes extraargs kp = propertyList (backupdir ++ " attic backup") $ props
& check (not <$> repoExists backupdir) (restored dirs backupdir)
& Cron.niceJob ("attic_backup" ++ backupdir) crontimes (User "root") "/" backupcmd