mirror of
https://github.com/Dokploy/dokploy.git
synced 2026-06-15 20:25:23 +02:00
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.
This commit is contained in:
@@ -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";
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user