From a08003f125298f5af2f508a3f259ba25553d27b1 Mon Sep 17 00:00:00 2001
From: teutat3s <teutates@mailbox.org>
Date: Wed, 2 Apr 2025 13:17:22 +0200
Subject: [PATCH] backups: only run restic prune on the last backup
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

After this change, only obs-portal backup will prune the repository of
old snapshots. This is the last backup service to run at 06:00 AM UTC.

This should avoid our nightly backups failing because of the exclusive
lock on the restic repo. We currently start the next backup while the
previous one is still pruning, which makes the newly started one fail
with:

repo already locked, waiting up to 0s for the lock
unable to create lock in backend: repository is already locked by PID 228…
---
 modules/forgejo/default.nix   | 5 -----
 modules/keycloak/default.nix  | 5 -----
 modules/mailman/default.nix   | 5 -----
 modules/mastodon/default.nix  | 5 -----
 modules/matrix/default.nix    | 5 -----
 modules/mediawiki/default.nix | 5 -----
 modules/nextcloud/default.nix | 5 -----
 7 files changed, 35 deletions(-)

diff --git a/modules/forgejo/default.nix b/modules/forgejo/default.nix
index bdb5d32..f47c585 100644
--- a/modules/forgejo/default.nix
+++ b/modules/forgejo/default.nix
@@ -197,10 +197,5 @@
     backupCleanupCommand = ''
       rm /tmp/forgejo-backup.sql
     '';
-    pruneOpts = [
-      "--keep-daily 7"
-      "--keep-weekly 4"
-      "--keep-monthly 3"
-    ];
   };
 }
diff --git a/modules/keycloak/default.nix b/modules/keycloak/default.nix
index d924717..a2ee9a4 100644
--- a/modules/keycloak/default.nix
+++ b/modules/keycloak/default.nix
@@ -71,11 +71,6 @@
       backupCleanupCommand = ''
         rm /tmp/keycloak-backup.sql
       '';
-      pruneOpts = [
-        "--keep-daily 7"
-        "--keep-weekly 4"
-        "--keep-monthly 3"
-      ];
     };
   };
 }
diff --git a/modules/mailman/default.nix b/modules/mailman/default.nix
index e5e2903..34c685f 100644
--- a/modules/mailman/default.nix
+++ b/modules/mailman/default.nix
@@ -93,10 +93,5 @@
     initialize = true;
     passwordFile = config.age.secrets."restic-repo-storagebox-nachtigall".path;
     repository = "sftp:u377325@u377325.your-storagebox.de:/backups";
-    pruneOpts = [
-      "--keep-daily 7"
-      "--keep-weekly 4"
-      "--keep-monthly 3"
-    ];
   };
 }
diff --git a/modules/mastodon/default.nix b/modules/mastodon/default.nix
index 2f16e33..4abec9c 100644
--- a/modules/mastodon/default.nix
+++ b/modules/mastodon/default.nix
@@ -132,10 +132,5 @@
     backupCleanupCommand = ''
       rm /tmp/mastodon-backup.sql
     '';
-    pruneOpts = [
-      "--keep-daily 7"
-      "--keep-weekly 4"
-      "--keep-monthly 3"
-    ];
   };
 }
diff --git a/modules/matrix/default.nix b/modules/matrix/default.nix
index 321e329..a3083b2 100644
--- a/modules/matrix/default.nix
+++ b/modules/matrix/default.nix
@@ -354,11 +354,6 @@ in
         rm /tmp/matrix-synapse-backup.sql
         rm /tmp/matrix-authentication-service-backup.sql
       '';
-      pruneOpts = [
-        "--keep-daily 7"
-        "--keep-weekly 4"
-        "--keep-monthly 3"
-      ];
     };
   };
 }
diff --git a/modules/mediawiki/default.nix b/modules/mediawiki/default.nix
index a78f5af..c39467a 100644
--- a/modules/mediawiki/default.nix
+++ b/modules/mediawiki/default.nix
@@ -255,10 +255,5 @@ in
     backupCleanupCommand = ''
       rm /tmp/mediawiki-backup.sql
     '';
-    pruneOpts = [
-      "--keep-daily 7"
-      "--keep-weekly 4"
-      "--keep-monthly 3"
-    ];
   };
 }
diff --git a/modules/nextcloud/default.nix b/modules/nextcloud/default.nix
index 8a1452a..4c052b8 100644
--- a/modules/nextcloud/default.nix
+++ b/modules/nextcloud/default.nix
@@ -285,10 +285,5 @@
     backupCleanupCommand = ''
       rm /tmp/nextcloud-backup.sql
     '';
-    pruneOpts = [
-      "--keep-daily 7"
-      "--keep-weekly 4"
-      "--keep-monthly 3"
-    ];
   };
 }