feat(backup): support cross-platform background database backups

This commit is contained in:
CSXFanMeng authored and GitHub committed 2026-09-23 12:29:56 +08:00
1 parent 250e0c0a10
commit 2f960f104c
56 files changed
+4195 -962

No files matched your search

@@ -2,6 +2,8 @@ import { describe, expect, it } from "vitest";
import {
databaseBackupFileNamePatternIsValid,
databaseBackupFilePath,
databaseBackupRunDirectory,
databaseBackupTimestamp,
sanitizeDatabaseBackupFileSegment,
databaseBackupRunsToPrune,
databaseBackupTableMatchesPattern,
@@ -28,6 +30,13 @@ function run(overrides: Record<string, unknown> = {}) {
}
describe("database backup run persistence", () => {
it("renders preview names in the saved zone rather than the browser zone", () => {
const instant = "2026-09-12T18:00:00Z";
expect(databaseBackupTimestamp(instant, "Asia/Shanghai")).toBe("20260913-020000");
expect(databaseBackupTimestamp(instant, "America/New_York")).toBe("20260912-140000");
expect(databaseBackupRunDirectory("/backups", "{date}/{timestamp}", "Daily", instant, "12345678", "Asia/Shanghai")).toBe("/backups/20260913/20260913020000");
expect(databaseBackupFilePath("/backups", "Daily", "app", instant, "12345678", "gzip", "{timestamp}", "Asia/Shanghai")).toBe("/backups/20260913-020000__app.sql.gz");
});
it("uses a gzip extension when the backup output is compressed", () => {
expect(databaseBackupFilePath("/backups", "Nightly", "app", startedAt, "run-12345678", "gzip")).toMatch(/\.sql\.gz$/);
});