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

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

Propellor.Property.Borg

Description

Support for the Borg backup tool https://github.com/borgbackup

Synopsis

- type BorgParam = String
- data BorgRepo
  - = BorgRepo String
  - | BorgRepoUsing [BorgRepoOpt] String
- data BorgRepoOpt
  - = UseSshKey FilePath
  - | UseUmask FileMode
  - | UsesEnvVar (String, String)
- data BorgEnc
  - = BorgEncNone
  - | BorgEncAuthenticated
  - | BorgEncAuthenticatedBlake2
  - | BorgEncRepokey
  - | BorgEncRepokeyBlake2
  - | BorgEncKeyfile
  - | BorgEncKeyfileBlake2
- installed :: Property DebianLike
- repoExists :: BorgRepo -> IO Bool
- init :: BorgRepo -> BorgEnc -> Property DebianLike
- restored :: FilePath -> BorgRepo -> Property DebianLike
- backup :: FilePath -> BorgRepo -> Times -> [BorgParam] -> [KeepPolicy] -> Property DebianLike
- data KeepPolicy
  - = KeepHours Int
  - | KeepDays Int
  - | KeepWeeks Int
  - | KeepMonths Int
  - | KeepYears Int

# Documentation

type BorgParam = String Source #

Parameter to pass to a borg command.

data BorgRepo Source #

A borg repository.

Constructors

BorgRepo String | Location of the repository, eg `BorgRepo "root@myserver:mntbackup/git.borg"`
BorgRepoUsing [BorgRepoOpt] String | Location of the repository, and additional options to use when accessing the repository.

data BorgRepoOpt Source #

Constructors

UseSshKey FilePath | Use to specify a ssh private key to use when accessing a BorgRepo.
UseUmask FileMode | Use to specify a umask to use when accessing BorgRepo.
UsesEnvVar (String, String) | Use to specify an environment variable to set when running borg on a BorgRepo.

data BorgEnc Source #

Borg Encryption type.

Constructors

BorgEncNone | No encryption, no authentication.
BorgEncAuthenticated | Authenticated, using SHA-256 for hash/MAC.
BorgEncAuthenticatedBlake2 | Authenticated, using Blake2b for hash/MAC.
BorgEncRepokey | Encrypted, storing the key in the repository, using SHA-256 for hash/MAC.
BorgEncRepokeyBlake2 | Encrypted, storing the key in the repository, using Blake2b for hash/MAC.
BorgEncKeyfile | Encrypted, storing the key outside of the repository, using SHA-256 for hash/MAC.
BorgEncKeyfileBlake2 | Encrypted, storing the key outside of the repository, using Blake2b for hash/MAC.

installed :: Property DebianLike Source #

repoExists :: BorgRepo -> IO Bool Source #

init :: BorgRepo -> BorgEnc -> Property DebianLike Source #

Inits a new borg repository

restored :: FilePath -> BorgRepo -> Property DebianLike Source #

Restores a directory from a borg 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 -> BorgRepo -> Times -> [BorgParam] -> [KeepPolicy] -> Property DebianLike Source #

Installs a cron job that causes a given directory to be backed up, by running borg 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:

    	& Borg.backup "/srv/git"
    		(BorgRepo "root@myserver:/mnt/backup/git.borg")
    		Cron.Daily
    		["--exclude=/srv/git/tobeignored"]
    		[Borg.KeepDays 7, Borg.KeepWeeks 4, Borg.KeepMonths 6, Borg.KeepYears 1]

Note that this property does not initialize the backup repository, so that will need to be done once, before-hand.

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

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 borg's man page for details.

Constructors

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