mirror of
https://github.com/Dokploy/dokploy
synced 2025-06-26 18:27:59 +00:00
Enhance RestoreBackup component to support compose backups by adding a database type selection and metadata handling. Update related API routes and schemas to accommodate new backup types, ensuring flexibility for various database configurations. Modify UI components to allow dynamic input for service names and database credentials based on the selected database type.
This commit is contained in:
@@ -21,7 +21,7 @@ export const runComposeBackup = async (
|
||||
const rcloneDestination = `:s3:${destination.bucket}/${bucketDestination}`;
|
||||
|
||||
const rcloneCommand = `rclone rcat ${rcloneFlags.join(" ")} "${rcloneDestination}"`;
|
||||
const command = `docker ps --filter "status=running" --filter "label=dokploy.backup.id=${backup.backupId}" --format "{{.ID}}" | head -n 1`;
|
||||
const command = getFindContainerCommand(compose, backup.serviceName || "");
|
||||
if (compose.serverId) {
|
||||
const { stdout } = await execAsyncRemote(compose.serverId, command);
|
||||
if (!stdout) {
|
||||
@@ -88,3 +88,26 @@ export const runComposeBackup = async (
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
export const getFindContainerCommand = (
|
||||
compose: Compose,
|
||||
serviceName: string,
|
||||
) => {
|
||||
const { appName, composeType } = compose;
|
||||
const labels =
|
||||
composeType === "stack"
|
||||
? {
|
||||
namespace: `label=com.docker.stack.namespace=${appName}`,
|
||||
service: `label=com.docker.swarm.service.name=${appName}_${serviceName}`,
|
||||
}
|
||||
: {
|
||||
project: `label=com.docker.compose.project=${appName}`,
|
||||
service: `label=com.docker.compose.service=${serviceName}`,
|
||||
};
|
||||
|
||||
const command = `docker ps --filter "status=running" \
|
||||
--filter "${Object.values(labels).join('" --filter "')}" \
|
||||
--format "{{.ID}}" | head -n 1`;
|
||||
|
||||
return command.trim();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user