From c05edb313fdd977a450883273b14a15ceec93051 Mon Sep 17 00:00:00 2001 From: Mauricio Siu <47042324+Siumauricio@users.noreply.github.com> Date: Thu, 26 Jun 2025 23:32:18 -0600 Subject: [PATCH] fix(backups): enhance database type handling in compose backup process - Added a new function to determine the database type based on the backup configuration. - Updated notifications to use the correct database type instead of a hardcoded value. --- packages/server/src/utils/backups/compose.ts | 22 +++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/packages/server/src/utils/backups/compose.ts b/packages/server/src/utils/backups/compose.ts index 82fb8828a..e431a5786 100644 --- a/packages/server/src/utils/backups/compose.ts +++ b/packages/server/src/utils/backups/compose.ts @@ -15,7 +15,7 @@ export const runComposeBackup = async ( ) => { const { projectId, name } = compose; const project = await findProjectById(projectId); - const { prefix } = backup; + const { prefix, databaseType } = backup; const destination = backup.destination; const backupFileName = `${new Date().toISOString()}.dump.gz`; const bucketDestination = `${normalizeS3Path(prefix)}${backupFileName}`; @@ -46,7 +46,7 @@ export const runComposeBackup = async ( await sendDatabaseBackupNotifications({ applicationName: name, projectName: project.name, - databaseType: "mongodb", + databaseType: getDatabaseType(databaseType), type: "success", organizationId: project.organizationId, }); @@ -57,7 +57,7 @@ export const runComposeBackup = async ( await sendDatabaseBackupNotifications({ applicationName: name, projectName: project.name, - databaseType: "mongodb", + databaseType: getDatabaseType(databaseType), type: "error", // @ts-ignore errorMessage: error?.message || "Error message not provided", @@ -68,3 +68,19 @@ export const runComposeBackup = async ( throw error; } }; + +const getDatabaseType = (databaseType: BackupSchedule["databaseType"]) => { + if (databaseType === "mongo") { + return "mongodb"; + } + if (databaseType === "postgres") { + return "postgres"; + } + if (databaseType === "mariadb") { + return "mariadb"; + } + if (databaseType === "mysql") { + return "mysql"; + } + return "mongodb"; +};