diff options
author | Franck Cuny <franck@fcuny.net> | 2022-03-11 19:31:26 -0800 |
---|---|---|
committer | Franck Cuny <franck@fcuny.net> | 2022-03-11 19:31:26 -0800 |
commit | 71288332e85f993628439cecfbaa6ee207d01f46 (patch) | |
tree | abcf96411b8ecff3a12a4a4a39b708d9212dd9df /hosts | |
parent | wm: ensure element is assigned to space #4 (diff) | |
download | world-71288332e85f993628439cecfbaa6ee207d01f46.tar.gz |
rclone: synchronize restic repo to GCS
Add a couple of secrets to store the configuration and the service account, and add a timer to synchronize the restic repository to a GCS bucket once a day.
Diffstat (limited to 'hosts')
-rw-r--r-- | hosts/common/server/rclone.nix | 29 |
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 + ''; + }; + }; +} |