propellor-5.10.1: property-based host configuration management in haskell

Maintainer | Félix Sipma <felix+propellor@gueux.org>
Safe Haskell | None
Language | Haskell98

Propellor.Property.Restic

Description

Support for the restic backup tool https://github.com/restic/restic

Synopsis

- data ResticRepo
  - = Direct FilePath
  - | SFTP User HostName FilePath
  - | REST Url
- installed :: Property DebianLike
- repoExists :: ResticRepo -> IO Bool
- init :: ResticRepo -> Property (HasInfo + DebianLike)
- restored :: FilePath -> ResticRepo -> Property (HasInfo + DebianLike)
- backup :: FilePath -> ResticRepo -> Times -> [ResticParam] -> [KeepPolicy] -> Property (HasInfo + DebianLike)
- backup' :: [FilePath] -> ResticRepo -> Times -> [ResticParam] -> [KeepPolicy] -> Property (HasInfo + DebianLike)
- data KeepPolicy
  - = KeepLast Int
  - | KeepHours Int
  - | KeepDays Int
  - | KeepWeeks Int
  - | KeepMonths Int
  - | KeepYears Int

# Documentation

data ResticRepo Source #

Constructors

Direct FilePath |
SFTP User HostName FilePath |
REST Url |

Instances

ConfigurableValue ResticRepo Source # |
Instance details Defined in Propellor.Property.Restic Methods val :: ResticRepo -> String Source #

installed :: Property DebianLike Source #

repoExists :: ResticRepo -> IO Bool Source #

init :: ResticRepo -> Property (HasInfo + DebianLike) Source #

Inits a new restic repository

restored :: FilePath -> ResticRepo -> Property (HasInfo + DebianLike) Source #

Restores a directory from a restic backup.

Only does anything if the directory does not exist, or exists, but is completely empty.

The restore is performed atomically; restoring to a temp directory and then moving it to the directory.

backup :: FilePath -> ResticRepo -> Times -> [ResticParam] -> [KeepPolicy] -> Property (HasInfo + DebianLike) Source #

Installs a cron job that causes a given directory to be backed up, by running restic with some parameters.

If the directory does not exist, or exists but is completely empty, this Property will immediately restore it from an existing backup.

So, this property can be used to deploy a directory of content to a host, while also ensuring any changes made to it get backed up. For example:

    	& Restic.backup "/srv/git"
    		(Restic.SFTP (User root) (HostName myserver) /mnt/backup/git.restic")
    		Cron.Daily
    		["--exclude=/srv/git/tobeignored"]
    		[Restic.KeepDays 7, Restic.KeepWeeks 4, Restic.KeepMonths 6, Restic.KeepYears 1]

Since restic uses a fair amount of system resources, only one restic backup job will be run at a time. Other jobs will wait their turns to run.

backup' :: [FilePath] -> ResticRepo -> Times -> [ResticParam] -> [KeepPolicy] -> Property (HasInfo + DebianLike) Source #

Does a backup, but does not automatically restore.

data KeepPolicy Source #

Policy for backup generations to keep. For example, KeepDays 30 will keep the latest backup for each day when a backup was made, and keep the last 30 such backups. When multiple KeepPolicies are combined together, backups meeting any policy are kept. See restic's man page for details.

Constructors

KeepLast Int |
KeepHours Int |
KeepDays Int |
KeepWeeks Int |
KeepMonths Int |
KeepYears Int |