restic(homeserver): add offsite backup

This commit is contained in:
wo2w 2026-02-08 13:01:18 -05:00
parent fc6dba68aa
commit c3d3bed26a
2 changed files with 32 additions and 7 deletions

View file

@ -4,12 +4,14 @@
sops.secrets = {
"restic/password" = {};
"restic/rest-auth.env" = {};
"restic/rclone/onedrive" = {};
};
systemd.services = {
db-backup = {
wantedBy = [ "restic-backups-main.service" ];
before = [ "restic-backups-main.service" ];
wantedBy = [ "restic-backups-main.service" "restic-backups-offsite.service" ];
before = [ "restic-backups-main.service" "restic-backups-offsite.service" ];
script = ''
DB_BACKUP_DIR=/var/backups/db-backup
@ -36,8 +38,8 @@
};
db-backup-cleanup = {
wantedBy = [ "restic-backups-main.service" ];
after = [ "restic-backups-main.service" ];
wantedBy = [ "restic-backups-main.service" "restic-backups-offsite.service" ];
after = [ "restic-backups-main.service" "restic-backups-offsite.service" ];
script = "rm -r /var/backups/db-backup";
serviceConfig.Type = "oneshot";
};
@ -83,6 +85,27 @@
];
};
services.restic.backups.offsite = {
user = "restic-backup";
package = pkgs.writeShellScriptBin "restic" ''
exec /run/wrappers/bin/restic "$@"
'';
passwordFile = config.sops.secrets."restic/password".path;
timerConfig = {
OnCalendar = "03:05";
Persistent = true;
};
repository = "rclone:remote:restic/drone";
initialize = true;
rcloneConfigFile = config.sops.secrets."restic/rclone/onedrive".path;
rcloneOptions = { temp-dir = "/tmp"; };
paths = config.services.restic.backups.main.paths;
exclude = config.services.restic.backups.main.exclude;
};
services.restic.backups.syncthing = {
user = "restic-backup";
package = pkgs.writeShellScriptBin "restic" ''
@ -92,7 +115,7 @@
environmentFile = config.sops.secrets."restic/rest-auth.env".path;
passwordFile = config.sops.secrets."restic/password".path;
timerConfig = {
OnCalendar = "03:05";
OnCalendar = "03:10";
Persistent = true;
};