Update deployment and backup components for improved handling and user experience

- Refined the `ShowDeployments` component to conditionally render `CancelQueues` and `RefreshToken` based on deployment type, enhancing flexibility.
- Removed unnecessary console logging in `RestoreBackup` and updated input field to disable when the database type is "web-server", improving user guidance.
- Enhanced logging in `runWebServerBackup` to provide clearer output during backup operations, ensuring better traceability of actions.
This commit is contained in:
Mauricio Siu
2025-05-04 13:19:45 -06:00
parent 06c9e43143
commit 9aa56870b0
6 changed files with 64 additions and 143 deletions

View File

@@ -42,35 +42,35 @@ export const runWebServerBackup = async (backup: BackupSchedule) => {
);
if (!containerId) {
writeStream.write("PostgreSQL container not found❌");
writeStream.write("Dokploy postgres container not found❌\n");
writeStream.end();
throw new Error("PostgreSQL container not found");
throw new Error("Dokploy postgres container not found");
}
writeStream.write(`PostgreSQL container ID: ${containerId}`);
writeStream.write(`Dokploy postgres container ID: ${containerId}\n`);
const postgresContainerId = containerId.trim();
const postgresCommand = `docker exec ${postgresContainerId} pg_dump -v -Fc -U dokploy -d dokploy > '${tempDir}/database.sql'`;
writeStream.write(`Running command: ${postgresCommand}`);
writeStream.write(`Running command: ${postgresCommand}\n`);
await execAsync(postgresCommand);
await execAsync(`cp -r ${BASE_PATH}/* ${tempDir}/filesystem/`);
writeStream.write("Copied filesystem to temp directory");
writeStream.write("Copied filesystem to temp directory\n");
await execAsync(
// Zip all .sql files since we created more than one
`cd ${tempDir} && zip -r ${backupFileName} *.sql filesystem/ > /dev/null 2>&1`,
);
writeStream.write("Zipped database and filesystem");
writeStream.write("Zipped database and filesystem\n");
const uploadCommand = `rclone copyto ${rcloneFlags.join(" ")} "${tempDir}/${backupFileName}" "${s3Path}"`;
writeStream.write(`Running command: ${uploadCommand}`);
writeStream.write(`Running command: ${uploadCommand}\n`);
await execAsync(uploadCommand);
writeStream.write("Uploaded backup to S3 ✅");
writeStream.write("Uploaded backup to S3 ✅\n");
writeStream.end();
await updateDeploymentStatus(deployment.deploymentId, "done");
return true;
@@ -80,7 +80,9 @@ export const runWebServerBackup = async (backup: BackupSchedule) => {
} catch (error) {
console.error("Backup error:", error);
writeStream.write("Backup error❌\n");
writeStream.write(error instanceof Error ? error.message : "Unknown error");
writeStream.write(
error instanceof Error ? error.message : "Unknown error\n",
);
writeStream.end();
await updateDeploymentStatus(deployment.deploymentId, "error");
throw error;