services.rsyncBackup = {
mountpoint = "/backup2";
- mailto = config.myEnv.rsync_backup.mailto;
profiles = config.myEnv.rsync_backup.profiles;
ssh_key_public = config.myEnv.rsync_backup.ssh_key.public;
ssh_key_private = config.myEnv.rsync_backup.ssh_key.private;
ssh_key = config.secrets.fullPaths."rsync_backup/identity";
- backup_head = mailto: ''
+ backup_head = ''
#!${pkgs.stdenv.shell}
EXCL_FROM=`mktemp`
FILES_FROM=`mktemp`
TMP_STDERR=`mktemp`
on_exit() {
- ${lib.optionalString (mailto != null) ''
- MAILTO="${mailto}"
if [ -s "$TMP_STDERR" ]; then
- cat "$TMP_STDERR" | ${pkgs.mailutils}/bin/mail -s "save_distant rsync error" "$MAILTO"
+ cat "$TMP_STDERR"
fi
- ''}
rm -f $TMP_STDERR $EXCL_FROM $FILES_FROM
}
type = lib.types.path;
description = "Path to the base folder for backups";
};
- mailto = lib.mkOption {
- type = lib.types.nullOr lib.types.str;
- default = null;
- description = "E-mail to send the report to";
- };
profiles = lib.mkOption {
type = lib.types.attrsOf profileModule;
default = {};
services.cron.systemCronJobs = let
backup = pkgs.writeScript "backup.sh" (builtins.concatStringsSep "\n" ([
- (backup_head cfg.mailto)
+ backup_head
] ++ lib.mapAttrsToList backup_profile cfg.profiles));
in [
''