about summary refs log tree commit diff
path: root/hosts/common/server/rclone.nix
blob: 808273e1a0307c42aafe07f79c3185b248514a0f (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
{ 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";
      environment.RCLONE_GCS_SERVICE_ACCOUNT_CREDENTIALS =
        config.age.secrets.rclone-gcs-sa.path;
      serviceConfig = {
        Type = "oneshot";
        ExecStart = [
          "${pkgs.rclone}/bin/rclone --config=${config.age.secrets.rclone-config.path} --fast-list --verbose sync /data/slow/backups gbackup:fcuny-backups-systems"
          "${pkgs.rclone}/bin/rclone --config=${config.age.secrets.rclone-config.path} --fast-list --verbose sync /data/slow/backups gbackup:fcuny-backups-users"
        ];
      };
    };
  };
}