about summary refs log tree commit diff
path: root/hosts/common/server/rclone.nix
blob: 549cf4da4fdb7ff1d2af064b7f556ca5b0e08746 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
{ config, pkgs, lib, ... }:

{
  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"
        ];
      };
    };
  };
}