mirror of
https://github.com/Dokploy/dokploy
synced 2025-06-26 18:27:59 +00:00
Enhance backup and deployment features
- Updated the RestoreBackupSchema to require serviceName for compose backups, improving validation and user feedback. - Refactored the ShowBackups component to include deployment information, enhancing the user interface and experience. - Introduced new SQL migration files to add backupId to the deployment table and appName to the backup table, improving data relationships and integrity. - Enhanced deployment creation logic to support backup deployments, ensuring better tracking and management of backup processes. - Improved backup and restore utility functions to streamline command execution and error handling during backup operations.
This commit is contained in:
@@ -8,6 +8,7 @@ import {
|
||||
import { sendDatabaseBackupNotifications } from "../notifications/database-backup";
|
||||
import { execAsync, execAsyncRemote } from "../process/execAsync";
|
||||
import { getS3Credentials, normalizeS3Path } from "./utils";
|
||||
import { createDeploymentBackup } from "@dokploy/server/services/deployment";
|
||||
|
||||
export const runPostgresBackup = async (
|
||||
postgres: Postgres,
|
||||
@@ -16,6 +17,11 @@ export const runPostgresBackup = async (
|
||||
const { appName, databaseUser, name, projectId } = postgres;
|
||||
const project = await findProjectById(projectId);
|
||||
|
||||
const deployment = await createDeploymentBackup({
|
||||
backupId: backup.backupId,
|
||||
title: "Postgres Backup",
|
||||
description: "Postgres Backup",
|
||||
});
|
||||
const { prefix, database } = backup;
|
||||
const destination = backup.destination;
|
||||
const backupFileName = `${new Date().toISOString()}.sql.gz`;
|
||||
@@ -40,7 +46,11 @@ export const runPostgresBackup = async (
|
||||
const { Id: containerId } = await getServiceContainer(appName);
|
||||
|
||||
const pgDumpCommand = `docker exec ${containerId} sh -c "pg_dump -Fc --no-acl --no-owner -h localhost -U ${databaseUser} --no-password '${database}' | gzip"`;
|
||||
await execAsync(`${pgDumpCommand} | ${rcloneCommand}`);
|
||||
|
||||
await execAsync(`${pgDumpCommand} | ${rcloneCommand}`, (data) => {
|
||||
console.log(data);
|
||||
});
|
||||
// await execAsync(`${pgDumpCommand} | ${rcloneCommand}`);
|
||||
}
|
||||
|
||||
await sendDatabaseBackupNotifications({
|
||||
|
||||
Reference in New Issue
Block a user