Run whole-data archives and restores in the background
A data archive or restore ran inside its request, which sent nothing until tar finished: Bun closes a silent socket after 10s (its default idleTimeout in production) and a proxy cuts it at about 100s, so the page showed a network error while the archive kept going, and a retry said another backup was already running. The routes now start the run (startDataBackupRun, refused while the backup lock is held) and answer at once. The page follows it by polling api/admin/backups/data-status: an archive reloads once written, a restore once the status comes from a new process after its restart, and a failure shows its error. A run in progress survives a reload. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -1,5 +1,10 @@
|
||||
import adminFetchHandler from "@/src/functions/frontend/admin-fetch-handler";
|
||||
import type { DataBackupRun } from "@/src/types";
|
||||
|
||||
/**
|
||||
* Starts the archive, which runs in the background on the server, and
|
||||
* hands back its run for the page to follow.
|
||||
*/
|
||||
export default async function createDataBackup() {
|
||||
if (
|
||||
!window.confirm(
|
||||
@@ -17,5 +22,6 @@ export default async function createDataBackup() {
|
||||
return {
|
||||
success: Boolean(res.success),
|
||||
msg: res.success ? undefined : res.msg || `Couldn't create archive`,
|
||||
run: res.success ? (res.singleRes as DataBackupRun | undefined) : undefined,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user