From af0bf7b2547fd1ea99a42d8f4eabc9b5fcbd8119 Mon Sep 17 00:00:00 2001 From: h7x4 Date: Thu, 29 Jan 2026 14:57:46 +0900 Subject: [PATCH] bicep/{postgres,mysql}: fix old backup deletion --- hosts/bicep/services/mysql/backup.nix | 2 +- hosts/bicep/services/postgresql/backup.nix | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/hosts/bicep/services/mysql/backup.nix b/hosts/bicep/services/mysql/backup.nix index 99035ff..17b9f08 100644 --- a/hosts/bicep/services/mysql/backup.nix +++ b/hosts/bicep/services/mysql/backup.nix @@ -56,7 +56,7 @@ in rm "$STATE_DIRECTORY/mysql-dump-latest.sql.zst" ||: ln -T "$OUT_FILE" "$STATE_DIRECTORY/mysql-dump-latest.sql.zst" - while [ $(find -type f "$STATE_DIRECTORY" -printf '.' | wc -c) -gt ${toString rotations} ]; do + while [ $(find -type f -printf '.' "$STATE_DIRECTORY" | wc -c) -gt ${toString (rotations + 1)} ]; do rm $(find "$STATE_DIRECTORY" -type f -printf '%T+ %p\n' | sort | head -n 1 | cut -d' ' -f2) done ''; diff --git a/hosts/bicep/services/postgresql/backup.nix b/hosts/bicep/services/postgresql/backup.nix index e3c9646..d9ca01a 100644 --- a/hosts/bicep/services/postgresql/backup.nix +++ b/hosts/bicep/services/postgresql/backup.nix @@ -57,7 +57,7 @@ in rm "$STATE_DIRECTORY/postgresql-dump-latest.sql.zst" ||: ln -T "$OUT_FILE" "$STATE_DIRECTORY/postgresql-dump-latest.sql.zst" - while [ $(find -type f "$STATE_DIRECTORY" -printf '.' | wc -c) -gt ${toString rotations} ]; do + while [ $(find -type f -printf '.' "$STATE_DIRECTORY" | wc -c) -gt ${toString (rotations + 1)} ]; do rm $(find "$STATE_DIRECTORY" -type f -printf '%T+ %p\n' | sort | head -n 1 | cut -d' ' -f2) done '';