diff options
author | Franck Cuny <franck@fcuny.net> | 2023-05-12 11:23:15 -0700 |
---|---|---|
committer | Franck Cuny <franck@fcuny.net> | 2023-05-12 11:24:09 -0700 |
commit | 70481fab46f4ef07f0638f9c03a0f6a7f98324de (patch) | |
tree | 0b4f74537f98628b82427c0a0fe7d6b87f04b63f /modules/services/backup/rsync.nix | |
parent | ops: remove everything under ops (diff) | |
download | world-70481fab46f4ef07f0638f9c03a0f6a7f98324de.tar.gz |
profiles/backup: configure the backup server
It creates the user, ensure sftp is configured correctly, and rsync the backups to rsync.net once a day.
Diffstat (limited to '')
-rw-r--r-- | modules/services/backup/rsync.nix | 57 |
1 files changed, 0 insertions, 57 deletions
diff --git a/modules/services/backup/rsync.nix b/modules/services/backup/rsync.nix deleted file mode 100644 index d58dfe9..0000000 --- a/modules/services/backup/rsync.nix +++ /dev/null @@ -1,57 +0,0 @@ -{ config, pkgs, lib, ... }: -let - cfg = config.my.services.backup.rsync; - secrets = config.age.secrets; - ssh-key-path = secrets."rsync.net/ssh-key".path; -in -{ - options.my.services.backup.rsync = with lib; { - enable = mkEnableOption "rsync backup service"; - - sourceDir = mkOption { - type = types.path; - example = "/data/slow/backups"; - description = "The directory to synchronize"; - }; - - destination = mkOption { - type = types.str; - example = "de2664@de2664.rsync.net:backups/"; - description = "The destination"; - }; - - timerConfig = mkOption { - default = { OnCalendar = "daily"; }; - example = { - OnCalendar = "00:05"; - RandomizedDelaySec = "5h"; - }; - description = '' - When to run rsync. See man systemd.timer for details. - ''; - }; - }; - - config = lib.mkIf cfg.enable { - systemd = { - timers.rsync-backups = { - description = "synchronize restic repository to rsync.net"; - wantedBy = [ "timers.target" ]; - partOf = [ "rsync-backups.service" ]; - timerConfig = cfg.timerConfig; - }; - services.rsync-backups = { - description = "synchronize restic repository to rsync.net"; - serviceConfig = { - Type = "oneshot"; - }; - script = '' - exec ${pkgs.rsync}/bin/rsync \ - -azq --delete \ - -e '${pkgs.openssh}/bin/ssh -i ${ssh-key-path}' \ - ${cfg.sourceDir} ${cfg.destination} - ''; - }; - }; - }; -} |