From bcf8b1607f9eac441e80d589844d4de0c8331177 Mon Sep 17 00:00:00 2001 From: h7x4 Date: Thu, 29 Jan 2026 14:53:07 +0900 Subject: [PATCH] bicep/{postgres,mysql}: use hardlink for latest backup file --- hosts/bicep/services/mysql/backup.nix | 3 ++- hosts/bicep/services/postgresql/backup.nix | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/hosts/bicep/services/mysql/backup.nix b/hosts/bicep/services/mysql/backup.nix index 1fee265..99035ff 100644 --- a/hosts/bicep/services/mysql/backup.nix +++ b/hosts/bicep/services/mysql/backup.nix @@ -52,8 +52,9 @@ in mysqldump --all-databases | zstd --compress -9 --rsyncable -o "$OUT_FILE" + # NOTE: this needs to be a hardlink for rrsync to allow sending it rm "$STATE_DIRECTORY/mysql-dump-latest.sql.zst" ||: - ln -s -T "$OUT_FILE" "$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 rm $(find "$STATE_DIRECTORY" -type f -printf '%T+ %p\n' | sort | head -n 1 | cut -d' ' -f2) diff --git a/hosts/bicep/services/postgresql/backup.nix b/hosts/bicep/services/postgresql/backup.nix index 5ef7f9f..e3c9646 100644 --- a/hosts/bicep/services/postgresql/backup.nix +++ b/hosts/bicep/services/postgresql/backup.nix @@ -53,8 +53,9 @@ in pg_dumpall -U postgres | zstd --compress -9 --rsyncable -o "$OUT_FILE" + # NOTE: this needs to be a hardlink for rrsync to allow sending it rm "$STATE_DIRECTORY/postgresql-dump-latest.sql.zst" ||: - ln -s -T "$OUT_FILE" "$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 rm $(find "$STATE_DIRECTORY" -type f -printf '%T+ %p\n' | sort | head -n 1 | cut -d' ' -f2)