feat: implement separate backup jobs for databases with MongoDB support

This commit is contained in:
biersoeckli
2025-12-09 14:46:35 +00:00
parent a2002c0416
commit 4af20278e0
12 changed files with 457 additions and 64 deletions
@@ -0,0 +1,20 @@
-- RedefineTables
PRAGMA defer_foreign_keys=ON;
PRAGMA foreign_keys=OFF;
CREATE TABLE "new_VolumeBackup" (
"id" TEXT NOT NULL PRIMARY KEY,
"volumeId" TEXT NOT NULL,
"targetId" TEXT NOT NULL,
"cron" TEXT NOT NULL,
"retention" INTEGER NOT NULL,
"useDatabaseBackup" BOOLEAN NOT NULL DEFAULT false,
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" DATETIME NOT NULL,
CONSTRAINT "VolumeBackup_volumeId_fkey" FOREIGN KEY ("volumeId") REFERENCES "AppVolume" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT "VolumeBackup_targetId_fkey" FOREIGN KEY ("targetId") REFERENCES "S3Target" ("id") ON DELETE CASCADE ON UPDATE CASCADE
);
INSERT INTO "new_VolumeBackup" ("createdAt", "cron", "id", "retention", "targetId", "updatedAt", "volumeId") SELECT "createdAt", "cron", "id", "retention", "targetId", "updatedAt", "volumeId" FROM "VolumeBackup";
DROP TABLE "VolumeBackup";
ALTER TABLE "new_VolumeBackup" RENAME TO "VolumeBackup";
PRAGMA foreign_keys=ON;
PRAGMA defer_foreign_keys=OFF;
+8 -7
View File
@@ -287,13 +287,14 @@ model S3Target {
}
model VolumeBackup {
id String @id @default(uuid())
volumeId String
volume AppVolume @relation(fields: [volumeId], references: [id], onDelete: Cascade)
targetId String
target S3Target @relation(fields: [targetId], references: [id], onDelete: Cascade)
cron String
retention Int
id String @id @default(uuid())
volumeId String
volume AppVolume @relation(fields: [volumeId], references: [id], onDelete: Cascade)
targetId String
target S3Target @relation(fields: [targetId], references: [id], onDelete: Cascade)
cron String
retention Int
useDatabaseBackup Boolean @default(false) // decides wether backup whole volume or make a dump of the databse (only for database volumes)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt