diff --git a/apps/dokploy/components/dashboard/database/backups/restore-backup.tsx b/apps/dokploy/components/dashboard/database/backups/restore-backup.tsx index c761fc70..5dcd7732 100644 --- a/apps/dokploy/components/dashboard/database/backups/restore-backup.tsx +++ b/apps/dokploy/components/dashboard/database/backups/restore-backup.tsx @@ -48,6 +48,7 @@ import { toast } from "sonner"; interface Props { databaseId: string; databaseType: Exclude; + serverId: string | null; } const RestoreBackupSchema = z.object({ @@ -76,7 +77,11 @@ const RestoreBackupSchema = z.object({ type RestoreBackup = z.infer; -export const RestoreBackup = ({ databaseId, databaseType }: Props) => { +export const RestoreBackup = ({ + databaseId, + databaseType, + serverId, +}: Props) => { const [isOpen, setIsOpen] = useState(false); const [search, setSearch] = useState(""); @@ -101,6 +106,7 @@ export const RestoreBackup = ({ databaseId, databaseType }: Props) => { { destinationId: destionationId, search, + serverId: serverId ?? "", }, { enabled: isOpen && !!destionationId, @@ -304,7 +310,9 @@ export const RestoreBackup = ({ databaseId, databaseType }: Props) => { form.setValue("backupFile", file); }} > - {file} +
+ {file} +
{ {postgres && postgres?.backups?.length > 0 && (
- +
)} @@ -108,7 +112,11 @@ export const ShowBackups = ({ id, type }: Props) => { databaseType={type} refetch={refetch} /> - + ) : ( diff --git a/apps/dokploy/server/api/routers/backup.ts b/apps/dokploy/server/api/routers/backup.ts index 8e585b7c..9ed8c6f9 100644 --- a/apps/dokploy/server/api/routers/backup.ts +++ b/apps/dokploy/server/api/routers/backup.ts @@ -31,7 +31,10 @@ import { import { TRPCError } from "@trpc/server"; import { z } from "zod"; -import { execAsync } from "@dokploy/server/utils/process/execAsync"; +import { + execAsync, + execAsyncRemote, +} from "@dokploy/server/utils/process/execAsync"; import { getS3Credentials } from "@dokploy/server/utils/backups/utils"; import { findDestinationById } from "@dokploy/server/services/destination"; import { @@ -229,6 +232,7 @@ export const backupRouter = createTRPCRouter({ z.object({ destinationId: z.string(), search: z.string(), + serverId: z.string().optional(), }), ) .query(async ({ input }) => { @@ -250,7 +254,16 @@ export const backupRouter = createTRPCRouter({ const searchPath = baseDir ? `${bucketPath}/${baseDir}` : bucketPath; const listCommand = `rclone lsf ${rcloneFlags.join(" ")} "${searchPath}" | head -n 100`; - const { stdout } = await execAsync(listCommand); + let stdout = ""; + + if (input.serverId) { + const result = await execAsyncRemote(listCommand, input.serverId); + stdout = result.stdout; + } else { + const result = await execAsync(listCommand); + stdout = result.stdout; + } + const files = stdout.split("\n").filter(Boolean); const results = baseDir