Fix data archives and restores failing on their own lock
startDataBackupRun already holds the backup run lock, but the archive (createDataBackup) and restoreDataBackup took it again, so every run failed a few seconds in with "Another backup or restore is already running". The writer and the restore now take no lock of their own. The run's notice (archiving, restoring, or why it failed) moves to its own line under the actions row so the buttons don't shift, and archiving reads in gray rather than the warning colour. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import grabSuperAdminUser from "@/src/functions/backend/backups/grab-super-admin-user";
|
||||
import createDataBackup from "@/src/functions/backend/backups/create-data-backup";
|
||||
import writeDataBackupArchive from "@/src/functions/backend/backups/write-data-backup-archive";
|
||||
import { startDataBackupRun } from "@/src/functions/backend/backups/data-backup-run";
|
||||
import logEvent, { grabRequestIP, logError } from "@/src/functions/backend/logger";
|
||||
import safeErrorMessage from "@/src/utils/safe-error-message";
|
||||
@@ -12,7 +12,8 @@ import type {
|
||||
/**
|
||||
* Starts archiving the whole `DATA_DIR` (Settings > Backups > Data
|
||||
* archives) and answers at once: the page polls `data-status` until the
|
||||
* archive is written.
|
||||
* archive is written. `startDataBackupRun` holds the backup run lock, so
|
||||
* the task calls the unlocked writer.
|
||||
*/
|
||||
export const handler: BunextAPIRouteHandler<
|
||||
APIResponseObject<DataBackupRun>
|
||||
@@ -33,7 +34,7 @@ export const handler: BunextAPIRouteHandler<
|
||||
kind: "archive",
|
||||
task: async () => {
|
||||
try {
|
||||
const backup = await createDataBackup();
|
||||
const backup = await writeDataBackupArchive();
|
||||
|
||||
await logEvent({
|
||||
title: "Data backup created",
|
||||
|
||||
Reference in New Issue
Block a user