From f20c73cdeeaf56ef371084f4e4039071113cf098 Mon Sep 17 00:00:00 2001 From: Mauricio Siu <47042324+Siumauricio@users.noreply.github.com> Date: Sat, 29 Mar 2025 23:27:13 -0600 Subject: [PATCH] Refactor temporary directory creation in web server backup: replace static path with dynamic temp directory using mkdtemp for improved file management and isolation during backup operations. --- packages/server/src/utils/backups/web-server.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/server/src/utils/backups/web-server.ts b/packages/server/src/utils/backups/web-server.ts index e7ae83c2..264ff764 100644 --- a/packages/server/src/utils/backups/web-server.ts +++ b/packages/server/src/utils/backups/web-server.ts @@ -3,6 +3,9 @@ import { execAsync } from "../process/execAsync"; import { getS3Credentials } from "./utils"; import { findDestinationById } from "@dokploy/server/services/destination"; import { IS_CLOUD, paths } from "@dokploy/server/constants"; +import { mkdtemp } from "node:fs/promises"; +import { join } from "node:path"; +import { tmpdir } from "node:os"; export const runWebServerBackup = async (backup: BackupSchedule) => { try { @@ -13,7 +16,7 @@ export const runWebServerBackup = async (backup: BackupSchedule) => { const rcloneFlags = getS3Credentials(destination); const timestamp = new Date().toISOString().replace(/[:.]/g, "-"); const { BASE_PATH } = paths(); - const tempDir = `${BASE_PATH}/temp-backup-${timestamp}`; + const tempDir = await mkdtemp(join(tmpdir(), "dokploy-backup-")); const backupFileName = `webserver-backup-${timestamp}.zip`; const s3Path = `:s3:${destination.bucket}/${backup.prefix}${backupFileName}`;