Implement metadata handling for database and compose backups. Update backup schemas to include metadata fields for various database types. Enhance backup creation and update processes to accommodate new metadata requirements. Modify UI components to support metadata input for different database types during backup operations.

This commit is contained in:
Mauricio Siu
2025-04-27 22:14:06 -06:00
parent 2ea2605ab1
commit 7c2eb63625
15 changed files with 6010 additions and 77 deletions

View File

@@ -10,6 +10,7 @@ import {
IS_CLOUD,
createBackup,
findBackupById,
findComposeByBackupId,
findMariadbByBackupId,
findMariadbById,
findMongoByBackupId,
@@ -31,6 +32,7 @@ import {
} from "@dokploy/server";
import { findDestinationById } from "@dokploy/server/services/destination";
import { runComposeBackup } from "@dokploy/server/utils/backups/compose";
import {
getS3Credentials,
normalizeS3Path,
@@ -240,9 +242,18 @@ export const backupRouter = createTRPCRouter({
manualBackupCompose: protectedProcedure
.input(apiFindOneBackup)
.mutation(async ({ input }) => {
// const backup = await findBackupById(input.backupId);
// await runComposeBackup(backup);
return true;
try {
const backup = await findBackupById(input.backupId);
const compose = await findComposeByBackupId(backup.backupId);
await runComposeBackup(compose, backup);
return true;
} catch (error) {
throw new TRPCError({
code: "BAD_REQUEST",
message: "Error running manual Compose backup ",
cause: error,
});
}
}),
manualBackupMongo: protectedProcedure
.input(apiFindOneBackup)

View File

@@ -27,7 +27,6 @@ import {
createMount,
deleteMount,
findComposeById,
findDomainsByComposeId,
findProjectById,
findServerById,
findUserById,
@@ -268,8 +267,7 @@ export const composeRouter = createTRPCRouter({
message: "You are not authorized to get this compose",
});
}
const domains = await findDomainsByComposeId(input.composeId);
const composeFile = await addDomainToCompose(compose, domains);
const composeFile = await addDomainToCompose(compose);
return dump(composeFile, {
lineWidth: 1000,
});
@@ -723,18 +721,4 @@ export const composeRouter = createTRPCRouter({
});
}
}),
manualBackup: protectedProcedure
.input(z.object({ composeId: z.string() }))
.mutation(async ({ input, ctx }) => {
const compose = await findComposeById(input.composeId);
if (compose.project.organizationId !== ctx.session.activeOrganizationId) {
throw new TRPCError({
code: "UNAUTHORIZED",
message: "You are not authorized to backup this compose",
});
}
await createBackup({
composeId: compose.composeId,
});
}),
});