From 5c3e7ed87f8bde9087919077e5448eef1f6ea7d6 Mon Sep 17 00:00:00 2001 From: vishalkadam47 Date: Sat, 31 May 2025 22:03:30 +0530 Subject: [PATCH] refactor: streamline cloud storage backup and restore processes by simplifying path construction and enhancing logging --- .../cloud-storage/restore-cloud-backup.tsx | 17 +-- .../cloud-storage/show-cloud-backups.tsx | 6 +- .../server/src/utils/backups/cloud-storage.ts | 106 +++++++++--------- 3 files changed, 69 insertions(+), 60 deletions(-) diff --git a/apps/dokploy/components/dashboard/database/backups/cloud-storage/restore-cloud-backup.tsx b/apps/dokploy/components/dashboard/database/backups/cloud-storage/restore-cloud-backup.tsx index d3a8f0cd..79bc16df 100644 --- a/apps/dokploy/components/dashboard/database/backups/cloud-storage/restore-cloud-backup.tsx +++ b/apps/dokploy/components/dashboard/database/backups/cloud-storage/restore-cloud-backup.tsx @@ -280,23 +280,25 @@ export const RestoreCloudBackup = ({ databaseId, databaseType }: Props) => { const remoteName = (() => { switch (selectedBackup.cloudStorageDestination?.provider) { case "drive": - return "dokploy-drive"; + return "drive"; case "dropbox": - return "dokploy-dropbox"; + return "dropbox"; case "box": - return "dokploy-box"; + return "box"; + case "ftp": + return "ftp"; + case "sftp": + return "sftp"; default: return selectedBackup.cloudStorageDestination?.provider; } })(); - const prefix = selectedBackup.prefix.startsWith("/") - ? selectedBackup.prefix.slice(1) - : selectedBackup.prefix; + const backupPath = `${remoteName}:${values.backupFile}`; await restoreBackup({ destinationId: selectedBackup.cloudStorageDestinationId, - backupFile: `${remoteName}:${prefix}/${values.backupFile}`, + backupFile: backupPath, databaseType, databaseName: values.databaseName, metadata: values.metadata, @@ -524,6 +526,7 @@ export const RestoreCloudBackup = ({ databaseId, databaseType }: Props) => { value={file.path} key={file.path} onSelect={() => { + console.log("Selected file:", file.path); form.setValue("backupFile", file.path); setSearch(""); setDebouncedSearchTerm(""); diff --git a/apps/dokploy/components/dashboard/database/backups/cloud-storage/show-cloud-backups.tsx b/apps/dokploy/components/dashboard/database/backups/cloud-storage/show-cloud-backups.tsx index 52410cac..29c6be36 100644 --- a/apps/dokploy/components/dashboard/database/backups/cloud-storage/show-cloud-backups.tsx +++ b/apps/dokploy/components/dashboard/database/backups/cloud-storage/show-cloud-backups.tsx @@ -178,9 +178,9 @@ export const ShowCloudBackups = ({ databaseId, databaseType }: Props) => {