Skip to content

Commit f20c73c

Browse files
committed
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.
1 parent 16bfc09 commit f20c73c

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

packages/server/src/utils/backups/web-server.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ import { execAsync } from "../process/execAsync";
33
import { getS3Credentials } from "./utils";
44
import { findDestinationById } from "@dokploy/server/services/destination";
55
import { IS_CLOUD, paths } from "@dokploy/server/constants";
6+
import { mkdtemp } from "node:fs/promises";
7+
import { join } from "node:path";
8+
import { tmpdir } from "node:os";
69

710
export const runWebServerBackup = async (backup: BackupSchedule) => {
811
try {
@@ -13,7 +16,7 @@ export const runWebServerBackup = async (backup: BackupSchedule) => {
1316
const rcloneFlags = getS3Credentials(destination);
1417
const timestamp = new Date().toISOString().replace(/[:.]/g, "-");
1518
const { BASE_PATH } = paths();
16-
const tempDir = `${BASE_PATH}/temp-backup-${timestamp}`;
19+
const tempDir = await mkdtemp(join(tmpdir(), "dokploy-backup-"));
1720
const backupFileName = `webserver-backup-${timestamp}.zip`;
1821
const s3Path = `:s3:${destination.bucket}/${backup.prefix}${backupFileName}`;
1922

0 commit comments

Comments
 (0)