Why not just do it as root? Because... ehm... hmm.. good point.

auto-flake-update
Yorick van Pelt 2016-09-21 13:43:04 +02:00
parent 4b596dea0f
commit ed5a55d734
2 changed files with 4 additions and 5 deletions

View File

@ -12,28 +12,28 @@ in
type = types.loaOf types.optionSet; type = types.loaOf types.optionSet;
options = { options = {
dir = mkOption { type = types.str; }; dir = mkOption { type = types.str; };
user = mkOption { type = types.str; };
remote = mkOption { type = types.str; }; remote = mkOption { type = types.str; };
keyfile = mkOption { type = types.str; }; keyfile = mkOption { type = types.str; };
keyid = mkOption { type = types.str; default = "root"; };
exclude = mkOption { type = types.str; default = ""; }; exclude = mkOption { type = types.str; default = ""; };
interval = mkOption { type = types.str; default = "weekly"; }; interval = mkOption { type = types.str; default = "weekly"; };
}; };
}; };
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
# TODO: generate key in pre-start?
systemd.services = let systemd.services = let
sectionToService = name: data: with data; { sectionToService = name: data: with data; {
description = "Back up ${name}"; description = "Back up ${name}";
serviceConfig = { serviceConfig = {
IOSchedulingClass="idle"; IOSchedulingClass="idle";
User=user;
#Type = "oneshot"; #Type = "oneshot";
}; };
script = '' script = ''
source ${keyfile} source ${keyfile}
${pkgs.duplicity}/bin/duplicity ${dir} ${remote} \ ${pkgs.duplicity}/bin/duplicity ${dir} ${remote} \
--ssl-cacert-file /etc/ssl/certs/ca-bundle.crt \ --ssl-cacert-file /etc/ssl/certs/ca-bundle.crt \
--encrypt-key ${user} \ --encrypt-key ${keyid} \
--exclude-filelist ${pkgs.writeText "dupignore" exclude} \ --exclude-filelist ${pkgs.writeText "dupignore" exclude} \
--asynchronous-upload \ --asynchronous-upload \
--volsize 100 \ --volsize 100 \

View File

@ -53,9 +53,8 @@ in
backups = { backups = {
mail = { mail = {
dir = "/var/spool/mail"; dir = "/var/spool/mail";
user = config.services.mailz.user;
remote = "webdavs://mail@yorickvp.stackstorage.com/remote.php/webdav//mail_bak"; remote = "webdavs://mail@yorickvp.stackstorage.com/remote.php/webdav//mail_bak";
keyfile = "/var/backup/mail_creds"; keyfile = "/var/backup/creds";
interval = "daily"; interval = "daily";
}; };
}; };