[GH-ISSUE #6087] [Issue]: Automatic backup writes without checking free space and retries a failed write every hour #3373

Closed
opened 2026-10-21 06:02:27 +07:00 by bsakaguchi · 2 comments
Owner

Originally created by @SonaGat3 on GitHub (Sep 12, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/6087

Originally assigned to: @SpicyMarinara on GitHub.

Summary

The automatic backup writes a full copy of the data folder into backups/ on the same disk without checking that the space exists. When the disk is nearly full the write fails with ENOSPC, the failure is recorded, and one hour later the next tick writes the whole archive again, filling the disk again. The live storage/ tables share that disk.

Expected behavior

Before writing, the job checks that the backups folder has at least roughly the size of the previous archive (or of the sources it is about to write) free, plus a margin. If not, it skips the run, records a clear lastError such as "Not enough free space for the automatic backup (X free, about Y needed)", and does not thrash the disk on every hourly tick.

Actual behavior

writeAutomaticBackup creates marinara-automatic-backup.zip.pending next to the previous archive, keeps the previous one until the new one is complete, and only then prunes to the retention count. Peak usage is therefore two full archives plus the retained history. Nothing checks free space first. On ENOSPC the pending file is removed and lastError is saved, but lastBackupAt is not advanced, so runAutomaticBackupIfDue treats the backup as still due and the hourly timer retries the full write. With Automatic backups kept allowed up to 9999 and Daily frequency, retained archives can also grow without bound relative to the disk.

Steps to reproduce

  1. Enable Automatic Backups, Daily, on a data folder whose size is more than half the free space of its disk.
  2. Wait for the first run (or toggle the setting to force it).
  3. The disk fills, the run fails with ENOSPC, and the UI shows the error.
  4. Every hour the same write is attempted again, and while the pending archive is growing any other write on that disk, including Marinara's own table files, can fail for lack of space.

Environment

  • Marinara Engine version: 2.4.5 (staging, 9bf5baaf0)
  • Install type: source (git checkout)
  • OS + version: Windows 10 22H2
  • Browser or app shell: n/a

Logs, screenshots, or video

[backup] Automatic backup failed
ENOSPC: no space left on device, write

Additional context

No user report yet; found while reviewing the backup code. Node 24 (the minimum in package.json) exposes fs.promises.statfs, and the server already uses statfsSync in packages/server/src/db/file-backed-store.ts, so a pre-flight check is a few lines in writeAutomaticBackup or runAutomaticBackupIfDue. writeFullBackupArchive already stats every source, so the expected size is available without extra I/O. The retention limit itself and the rotation order look correct and would stay as they are.

Template check

Please uncheck (untick) the box below before submitting so we know you read the template. It is intentionally pre-checked:

  • I DID NOT read this template and provide the requested details.
Originally created by @SonaGat3 on GitHub (Sep 12, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/6087 Originally assigned to: @SpicyMarinara on GitHub. ## Summary The automatic backup writes a full copy of the data folder into `backups/` on the same disk without checking that the space exists. When the disk is nearly full the write fails with ENOSPC, the failure is recorded, and one hour later the next tick writes the whole archive again, filling the disk again. The live `storage/` tables share that disk. ## Expected behavior Before writing, the job checks that the backups folder has at least roughly the size of the previous archive (or of the sources it is about to write) free, plus a margin. If not, it skips the run, records a clear `lastError` such as "Not enough free space for the automatic backup (X free, about Y needed)", and does not thrash the disk on every hourly tick. ## Actual behavior `writeAutomaticBackup` creates `marinara-automatic-backup.zip.pending` next to the previous archive, keeps the previous one until the new one is complete, and only then prunes to the retention count. Peak usage is therefore two full archives plus the retained history. Nothing checks free space first. On ENOSPC the pending file is removed and `lastError` is saved, but `lastBackupAt` is not advanced, so `runAutomaticBackupIfDue` treats the backup as still due and the hourly timer retries the full write. With **Automatic backups kept** allowed up to 9999 and Daily frequency, retained archives can also grow without bound relative to the disk. ## Steps to reproduce 1. Enable **Automatic Backups**, Daily, on a data folder whose size is more than half the free space of its disk. 2. Wait for the first run (or toggle the setting to force it). 3. The disk fills, the run fails with ENOSPC, and the UI shows the error. 4. Every hour the same write is attempted again, and while the pending archive is growing any other write on that disk, including Marinara's own table files, can fail for lack of space. ## Environment - Marinara Engine version: 2.4.5 (`staging`, `9bf5baaf0`) - Install type: source (git checkout) - OS + version: Windows 10 22H2 - Browser or app shell: n/a ## Logs, screenshots, or video [backup] Automatic backup failed ENOSPC: no space left on device, write ## Additional context No user report yet; found while reviewing the backup code. Node 24 (the minimum in `package.json`) exposes `fs.promises.statfs`, and the server already uses `statfsSync` in `packages/server/src/db/file-backed-store.ts`, so a pre-flight check is a few lines in `writeAutomaticBackup` or `runAutomaticBackupIfDue`. `writeFullBackupArchive` already stats every source, so the expected size is available without extra I/O. The retention limit itself and the rotation order look correct and would stay as they are. ## Template check Please **uncheck (untick)** the box below before submitting so we know you read the template. It is intentionally pre-checked: - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-21 06:02:27 +07:00
Author
Owner

@SpicyMarinara commented on GitHub (Sep 12, 2026):

The translated backup guidance is being published separately to docs-i18n in #6097. The existing implementation and regression work remain in #6088.

<!-- gh-comment-id:5647424290 --> @SpicyMarinara commented on GitHub (Sep 12, 2026): The translated backup guidance is being published separately to docs-i18n in #6097. The existing implementation and regression work remain in #6088.
Author
Owner

@SpicyMarinara commented on GitHub (Sep 12, 2026):

Fixed on staging in #6095.

Automatic backups check the backups volume before writing and leave the previous archive intact when there is insufficient space. A real backup-route regression verifies the error, no partial archive, and a successful retry after space becomes available. Original patch from #6088 is preserved; the translated guide is covered by #6097.

<!-- gh-comment-id:5647849096 --> @SpicyMarinara commented on GitHub (Sep 12, 2026): Fixed on staging in #6095. Automatic backups check the backups volume before writing and leave the previous archive intact when there is insufficient space. A real backup-route regression verifies the error, no partial archive, and a successful retry after space becomes available. Original patch from #6088 is preserved; the translated guide is covered by #6097.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#3373
No description provided.