diff options
author | Franck Cuny <franck@fcuny.net> | 2022-04-06 12:42:20 -0700 |
---|---|---|
committer | Franck Cuny <franck@fcuny.net> | 2022-04-06 12:42:20 -0700 |
commit | 81fb05398a2c8251936be4bfa0ed679f0cf3825f (patch) | |
tree | b9b0b3945b34bc43d2afa01c2029cf8b5f77eaa1 /modules/services/rclone | |
parent | refactor gitea as a module (diff) | |
download | world-81fb05398a2c8251936be4bfa0ed679f0cf3825f.tar.gz |
refactor rclone to a module
Diffstat (limited to 'modules/services/rclone')
-rw-r--r-- | modules/services/rclone/default.nix | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/modules/services/rclone/default.nix b/modules/services/rclone/default.nix new file mode 100644 index 0000000..1ccf5df --- /dev/null +++ b/modules/services/rclone/default.nix @@ -0,0 +1,37 @@ +{ config, pkgs, lib, ... }: +let cfg = config.my.services.rclone; +in { + options.my.services.rclone = with lib; { + enable = mkEnableOption "rclone backup service"; + }; + + config = lib.mkIf cfg.enable { + age.secrets.rclone-gcs-sa.file = + ../../../secrets/rclone/gcs_service_account.json.age; + + age.secrets.rclone-config.file = ../../../secrets/rclone/config.ini.age; + + systemd = { + packages = [ pkgs.rclone ]; + timers.rclone-sync = { + description = "synchronize restic repository to GCS"; + wantedBy = [ "timers.target" ]; + partOf = [ "rclone-sync.service" ]; + timerConfig = { OnCalendar = "02:00"; }; + }; + services.rclone-sync = { + description = "synchronize restic repository to GCS"; + serviceConfig = let + rcloneOptions = + "--config=${config.age.secrets.rclone-config.path} --gcs-service-account-file=${config.age.secrets.rclone-gcs-sa.path} --fast-list --verbose"; + in { + Type = "oneshot"; + ExecStart = [ + "${pkgs.rclone}/bin/rclone ${rcloneOptions} sync /data/slow/backups/systems gbackup:fcuny-backups-systems" + "${pkgs.rclone}/bin/rclone ${rcloneOptions} sync /data/slow/backups/users gbackup:fcuny-backups-users" + ]; + }; + }; + }; + }; +} |