summaryrefslogtreecommitdiff
path: root/config/backups.nix
diff options
context:
space:
mode:
authorquentin@aristote.fr <quentin@aristote.fr>2026-11-29 19:08:48 +0100
committerquentin@aristote.fr <quentin@aristote.fr>2026-11-29 19:32:00 +0100
commit7d6924fc474d5712810d8772b4961c7f78cead8d (patch)
tree010cd27cea4f991315ef4896543a6221e9511fba /config/backups.nix
parent3f6546d21958ec77acde8747ae9b3b8df85bb60a (diff)
downloadhermaphroditos-7d6924fc474d5712810d8772b4961c7f78cead8d.tar.gz
hermaphroditos-7d6924fc474d5712810d8772b4961c7f78cead8d.tar.bz2
hermaphroditos-7d6924fc474d5712810d8772b4961c7f78cead8d.tar.xz
enable backupsHEADmaster
Diffstat (limited to 'config/backups.nix')
-rw-r--r--config/backups.nix53
1 files changed, 53 insertions, 0 deletions
diff --git a/config/backups.nix b/config/backups.nix
new file mode 100644
index 0000000..c6f8e3a
--- /dev/null
+++ b/config/backups.nix
@@ -0,0 +1,53 @@
+{
+ config,
+ lib,
+ pkgs,
+ ...
+}:
+
+let
+ host = "ds218.aristote.mesh";
+ remoteUser = "hephaistos";
+ # IIRC, key-based ssh login is impossible on DSM 6.2
+ sshpass = "${pkgs.sshpass}/bin/sshpass -f /etc/restic/sftp.key";
+in
+{
+ programs.ssh = {
+ knownHosts."${host}".publicKey =
+ "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIAoYu1E0/Ej+w+51mt0foRUxkrScN15kTa0cIBT5SnUq";
+ extraConfig = ''
+ Host ${host}
+ User ${remoteUser}
+ ServerAliveInterval 60
+ ServerAliveCountMax 240
+ '';
+ };
+
+ services.restic.backups.srv = {
+ extraOptions = [
+ "sftp.command='${sshpass} ssh ${host} -s sftp'"
+ ];
+ passwordFile = "/etc/restic/srv.key";
+ paths = [
+ "/srv"
+ ];
+ repository = "sftp:${host}:/${remoteUser}";
+ timerConfig = {
+ # the NAS is on between 10pm and 6am
+ OnCalendar = "23:00";
+ RandomizedDelaySec = "1h";
+ Persistent = true;
+ };
+ pruneOpts = [ "--keep-daily 7" ];
+ initialize = true;
+ };
+ systemd.services.restic-backups-srv = lib.mkMerge [
+ {
+ personal.monitor = true;
+ }
+ (pkgs.lib.personal.services.checkNetwork {
+ hosts = [ "ds218.aristote.mesh" ];
+ restart = false;
+ })
+ ];
+}