summaryrefslogtreecommitdiffstats
path: root/default.nix
diff options
context:
space:
mode:
authorPhilipp Dörfler <phdoerfler@gmail.com>2018-03-03 01:28:20 +0000
committerPhilipp Dörfler <phdoerfler@gmail.com>2018-03-04 14:36:42 +0000
commitb53364715d2149df7e326b07624555753de91300 (patch)
treee09d6f17ec38f6dc5cc6399511b561de7b5f2ecb /default.nix
parente5e3e61f97671cb4ba828d413e03625b604a5ce5 (diff)
Added basic support for borgbackup
Diffstat (limited to 'default.nix')
-rw-r--r--default.nix132
1 files changed, 131 insertions, 1 deletions
diff --git a/default.nix b/default.nix
index 168bbaf..77dca63 100644
--- a/default.nix
+++ b/default.nix
@@ -477,9 +477,138 @@ in
description = ''
The configuration used for monitoring via monit.
Use a mail address that you actively check and set it via 'set alert ...'.
+ '';
+ };
+ };
+
+ borgbackup = {
+ enable = mkEnableOption "backup via borgbackup";
+
+ repoLocation = mkOption {
+ type = types.string;
+ default = "/var/borgbackup";
+ description = ''
+ The location where borg saves the backups.
+ This can be a local path or a remote location such as user@host:/path/to/repo.
+ It is exported and thus available as an environment variable to cmdPreexec and cmdPostexec.
+ '';
+ };
+
+ startAt = mkOption {
+ type = types.string;
+ default = "hourly";
+ description = "When or how often the backup should run. Must be in the format described in systemd.time 7.";
+ };
+
+ user = mkOption {
+ type = types.string;
+ default = "virtualMail";
+ description = "The user borg and its launch script is run as.";
+ };
+
+ group = mkOption {
+ type = types.string;
+ default = "virtualMail";
+ description = "The group borg and its launch script is run as.";
+ };
+
+ compression = {
+ method = mkOption {
+ type = types.nullOr (types.enum ["none" "lz4" "zstd" "zlib" "lzma"]);
+ default = null;
+ description = "Leaving this unset allows borg to choose. The default for borg 1.1.4 is lz4.";
+ };
+
+ level = mkOption {
+ type = types.nullOr types.int;
+ default = null;
+ description = ''
+ Denotes the level of compression used by borg.
+ Most methods accept levels from 0 to 9 but zstd which accepts values from 1 to 22.
+ If null the decision is left up to borg.
'';
- };
};
+
+ auto = mkOption {
+ type = types.bool;
+ default = false;
+ description = "Leaves it to borg to determine whether an individual file should be compressed.";
+ };
+ };
+
+ encryption = {
+ method = mkOption {
+ type = types.enum [
+ "none"
+ "authenticated"
+ "authenticated-blake2"
+ "repokey"
+ "keyfile"
+ "repokey-blake2"
+ "keyfile-blake2"
+ ];
+ default = "none";
+ description = ''
+ The backup can be encrypted by choosing any other value than 'none'.
+ When using encryption the password / passphrase must be provided in passphraseFile.
+ '';
+ };
+
+ passphraseFile = mkOption {
+ type = types.nullOr types.path;
+ default = null;
+ };
+ };
+
+ name = mkOption {
+ type = types.string;
+ default = "{hostname}-{user}-{now}";
+ description = ''
+ The name of the individual backups as used by borg.
+ Certain placeholders will be replaced by borg.
+ '';
+ };
+
+ locations = mkOption {
+ type = types.listOf types.path;
+ default = [cfg.mailDirectory];
+ description = "The locations that are to be backed up by borg.";
+ };
+
+ extraArgumentsForInit = mkOption {
+ type = types.listOf types.string;
+ default = ["--critical"];
+ description = "Additional arguments to add to the borg init command line.";
+ };
+
+ extraArgumentsForCreate = mkOption {
+ type = types.listOf types.string;
+ default = [ ];
+ description = "Additional arguments to add to the borg create command line e.g. '--stats'.";
+ };
+
+ cmdPreexec = mkOption {
+ type = types.nullOr types.string;
+ default = null;
+ description = ''
+ The command to be executed before each backup operation.
+ This is called prior to borg init in the same script that runs borg init and create and cmdPostexec.
+ Example:
+ export BORG_RSH="ssh -i /path/to/private/key"
+ '';
+ };
+
+ cmdPostexec = mkOption {
+ type = types.nullOr types.string;
+ default = null;
+ description = ''
+ The command to be executed after each backup operation.
+ This is called after borg create completed successfully and in the same script that runs
+ cmdPreexec, borg init and create.
+ '';
+ };
+
+ };
backup = {
enable = mkEnableOption "backup via rsnapshot";
@@ -542,6 +671,7 @@ in
};
imports = [
+ ./mail-server/borgbackup.nix
./mail-server/rsnapshot.nix
./mail-server/clamav.nix
./mail-server/monit.nix