Skip to content

Keep the last good backup until there is a new one - #724

Merged
blaipr merged 1 commit into
mainfrom
fix/keep-the-last-good-backup
Aug 13, 2026
Merged

Keep the last good backup until there is a new one#724
blaipr merged 1 commit into
mainfrom
fix/keep-the-last-good-backup

Conversation

@blaipr

@blaipr blaipr commented Aug 13, 2026

Copy link
Copy Markdown
Member

The bug

The same ordering the export had (#722), with more at stake: BackupFile::doBackup() called deleteOldBackups() before writing the new archives.

So a backup that failed part-way — an unreadable table, a directory it could not archive, a full disk — took the previous database dump and application archive with it, and left the installation with no backup at all. The existing failure test drove exactly that path; it just had nothing on disk to notice was gone.

The fix

Delete afterwards, keeping anything named with this run's hash — which is what the archives it just wrote are named with, whatever extension the archive handler settled on. A successful backup still replaces the previous one, so the directory does not accumulate.

FileSystem gains the variant that does the skipping; deleteByPattern() is now that call with nothing kept.

Testing

A test that seeds a previous archive, makes the run fail, and asserts it is still there. It fails against the old ordering.

Like the export's, it uses a real directory: the cleanup globs, and glob() does not see a stream wrapper, so against the harness's virtual filesystem it would pass while proving nothing.

Unit suite green: 3074. Integration backup tests: 18 green.

Same ordering the export had: the previous archives were deleted before the new
ones were written, so a backup that failed part-way — an unreadable table, a
directory it could not archive, a full disk — took the last backup with it and
left the installation with none.

Delete afterwards instead, keeping anything named with this run's hash, which is
what the archives it just wrote are named with whatever extension the archive
handler settled on. A successful backup still replaces the previous one.

FileSystem gains the variant that does the skipping; deleteByPattern is now that
call with nothing kept.

The test uses a real directory rather than the harness's virtual one, because
the cleanup globs and glob does not see a stream wrapper. It fails against the
old ordering.
@blaipr
blaipr merged commit 6d0026f into main Aug 13, 2026
8 checks passed
@blaipr
blaipr deleted the fix/keep-the-last-good-backup branch August 13, 2026 20:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant