fix(backup): enhance backup configuration and history management

This commit is contained in:
二丫讲梵 authored and GitHub committed 2026-09-09 00:15:12 +08:00
1 parent 789740c9be
commit 69ef418d5f
23 files changed
+623 -92

No files matched your search

+18
View File
@@ -5,6 +5,8 @@ import {
DatabaseBackupConnectionQueue,
databaseBackupAggregateExportStatus,
databaseBackupFilePath,
databaseBackupRunDirectory,
databaseBackupRunDirectoryPatternIsValid,
databaseBackupProgressPercent,
databaseBackupRunsToPrune,
databaseBackupScheduleIsDue,
@@ -133,6 +135,22 @@ test("backup file names are unique and safe for schema-aware exports", () => {
assert.equal(path, "C:\\backups\\dbx-backup__Nightly_ prod__20260716-020304__app_private__12345678.sql");
});
test("scheduled runs render a user-defined relative directory template", () => {
const directory = databaseBackupRunDirectory(
"C:\\backups",
"archives/{schedule}/{date}/{timestamp}-{runId}",
"Nightly: prod",
new Date(2026, 6, 16, 2, 3, 4),
"12345678-abcd",
);
assert.equal(directory, "C:\\backups\\archives\\Nightly_ prod\\20260716\\20260716020304-12345678");
assert.equal(databaseBackupRunDirectoryPatternIsValid("{schedule}/{runId}"), true);
assert.equal(databaseBackupRunDirectoryPatternIsValid("dbx-backup_{timestamp}"), true);
assert.equal(databaseBackupRunDirectoryPatternIsValid("../{runId}"), false);
assert.equal(databaseBackupRunDirectoryPatternIsValid("daily"), true);
});
test("retention pruning keeps the newest successful runs", () => {
const runs = [run("new", "2026-07-16T03:00:00.000Z"), run("middle", "2026-07-16T02:00:00.000Z"), run("old", "2026-07-16T01:00:00.000Z")];