about summary refs log tree commit diff
path: root/hosts/common/server
diff options
context:
space:
mode:
Diffstat (limited to 'hosts/common/server')
-rw-r--r--hosts/common/server/rclone.nix29
1 files changed, 29 insertions, 0 deletions
diff --git a/hosts/common/server/rclone.nix b/hosts/common/server/rclone.nix
new file mode 100644
index 0000000..5e1a4d6
--- /dev/null
+++ b/hosts/common/server/rclone.nix
@@ -0,0 +1,29 @@
+{ config, pkgs, lib, ... }:
+
+{
+  environment.systemPackages = with pkgs; [ rclone ];
+
+  age.secrets.rclone-gcs-sa.file =
+    ../../../secrets/rclone/gcs_service_account.json.age;
+
+  age.secrets.rclone-config.file = ../../../secrets/rclone/config.ini.age;
+
+  systemd = {
+    timers.rclone-sync = {
+      wantedBy = [ "timers.target" ];
+      partOf = [ "rclone-sync.service" ];
+      timerConfig = { OnCalendar = "02:00"; };
+    };
+    services.rclone-sync = let rcloneOptions = "--fast-list --verbose";
+    in {
+      serviceConfig.Type = "oneshot";
+      serviceConfig.Environment = {
+        RCLONE_GCS_SERVICE_ACCOUNT_CREDENTIALS =
+          config.age.secrets.rclone-gcs-sa.path;
+      };
+      script = ''
+        ${pkgs.rclone}/bin/rclone --config=${age.secrets.rclone-config.path} sync ${rcloneOptions} /data/slow/backups gbackup:fcuny-backups
+      '';
+    };
+  };
+}