Implement support for compose backups in runJobs function. Enhance backup handling by checking server status and executing runComposeBackup for compose database types. Update backup structure to include compose details.

This commit is contained in:
Mauricio Siu 2025-04-27 23:12:11 -06:00
parent 77d7dc1f22
commit ddcb22dff9
2 changed files with 10 additions and 2 deletions

View File

@ -16,13 +16,14 @@ import { eq } from "drizzle-orm";
import { logger } from "./logger.js"; import { logger } from "./logger.js";
import { scheduleJob } from "./queue.js"; import { scheduleJob } from "./queue.js";
import type { QueueJob } from "./schema.js"; import type { QueueJob } from "./schema.js";
import { runComposeBackup } from "@dokploy/server/src/utils/backups/compose.js";
export const runJobs = async (job: QueueJob) => { export const runJobs = async (job: QueueJob) => {
try { try {
if (job.type === "backup") { if (job.type === "backup") {
const { backupId } = job; const { backupId } = job;
const backup = await findBackupById(backupId); const backup = await findBackupById(backupId);
const { databaseType, postgres, mysql, mongo, mariadb } = backup; const { databaseType, postgres, mysql, mongo, mariadb, compose } = backup;
if (databaseType === "postgres" && postgres) { if (databaseType === "postgres" && postgres) {
const server = await findServerById(postgres.serverId as string); const server = await findServerById(postgres.serverId as string);
@ -56,6 +57,14 @@ export const runJobs = async (job: QueueJob) => {
} }
await runMariadbBackup(mariadb, backup); await runMariadbBackup(mariadb, backup);
await keepLatestNBackups(backup, server.serverId); await keepLatestNBackups(backup, server.serverId);
} else if (databaseType === "compose" && compose) {
const server = await findServerById(compose.serverId as string);
if (server.serverStatus === "inactive") {
logger.info("Server is inactive");
return;
}
await runComposeBackup(compose, backup);
await keepLatestNBackups(backup, server.serverId);
} }
} }
if (job.type === "server") { if (job.type === "server") {

View File

@ -88,4 +88,3 @@ export const runComposeBackup = async (
throw error; throw error;
} }
}; };
// mongorestore -d monguito -u mongo -p Bqh7AQl-PRbnBu --authenticationDatabase admin --gzip --archive=2024-04-13T05:03:58.937Z.dump.gz