mirror of
https://github.com/Dokploy/dokploy.git
synced 2026-07-05 05:55:21 +02: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:
@@ -5,6 +5,52 @@ import { Client } from "ssh2";
|
||||
|
||||
export const execAsync = util.promisify(exec);
|
||||
|
||||
interface ExecOptions {
|
||||
cwd?: string;
|
||||
env?: NodeJS.ProcessEnv;
|
||||
}
|
||||
|
||||
export const execAsyncStream = (
|
||||
command: string,
|
||||
onData?: (data: string) => void,
|
||||
options: ExecOptions = {},
|
||||
): Promise<{ stdout: string; stderr: string }> => {
|
||||
return new Promise((resolve, reject) => {
|
||||
let stdoutComplete = "";
|
||||
let stderrComplete = "";
|
||||
|
||||
const childProcess = exec(command, options, (error) => {
|
||||
if (error) {
|
||||
console.log(error);
|
||||
reject(error);
|
||||
return;
|
||||
}
|
||||
resolve({ stdout: stdoutComplete, stderr: stderrComplete });
|
||||
});
|
||||
|
||||
childProcess.stdout?.on("data", (data: Buffer | string) => {
|
||||
const stringData = data.toString();
|
||||
stdoutComplete += stringData;
|
||||
if (onData) {
|
||||
onData(stringData);
|
||||
}
|
||||
});
|
||||
|
||||
childProcess.stderr?.on("data", (data: Buffer | string) => {
|
||||
const stringData = data.toString();
|
||||
stderrComplete += stringData;
|
||||
if (onData) {
|
||||
onData(stringData);
|
||||
}
|
||||
});
|
||||
|
||||
childProcess.on("error", (error) => {
|
||||
console.log(error);
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
export const execFileAsync = async (
|
||||
command: string,
|
||||
args: string[],
|
||||
|
||||
Reference in New Issue
Block a user