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 [
''