mirror of
https://github.com/Dokploy/dokploy
synced 2025-06-26 18:27:59 +00:00
Enhance backup and deployment features
- Updated the RestoreBackupSchema to require serviceName for compose backups, improving validation and user feedback. - Refactored the ShowBackups component to include deployment information, enhancing the user interface and experience. - Introduced new SQL migration files to add backupId to the deployment table and appName to the backup table, improving data relationships and integrity. - Enhanced deployment creation logic to support backup deployments, ensuring better tracking and management of backup processes. - Improved backup and restore utility functions to streamline command execution and error handling during backup operations.
This commit is contained in:
@@ -103,7 +103,6 @@ const RestoreBackupSchema = z
|
||||
.enum(["postgres", "mariadb", "mysql", "mongo", "web-server"])
|
||||
.optional(),
|
||||
backupType: z.enum(["database", "compose"]).default("database"),
|
||||
serviceName: z.string().nullable().optional(),
|
||||
metadata: z
|
||||
.object({
|
||||
postgres: z
|
||||
@@ -128,6 +127,7 @@ const RestoreBackupSchema = z
|
||||
databaseRootPassword: z.string(),
|
||||
})
|
||||
.optional(),
|
||||
serviceName: z.string().optional(),
|
||||
})
|
||||
.optional(),
|
||||
})
|
||||
@@ -139,6 +139,17 @@ const RestoreBackupSchema = z
|
||||
path: ["databaseType"],
|
||||
});
|
||||
}
|
||||
|
||||
console.log(data.backupType, { metadata: data.metadata });
|
||||
|
||||
if (data.backupType === "compose" && !data.metadata?.serviceName) {
|
||||
ctx.addIssue({
|
||||
code: z.ZodIssueCode.custom,
|
||||
message: "Service name is required for compose backups",
|
||||
path: ["metadata", "serviceName"],
|
||||
});
|
||||
}
|
||||
|
||||
if (data.backupType === "compose" && data.databaseType) {
|
||||
if (data.databaseType === "postgres") {
|
||||
if (!data.metadata?.postgres?.databaseUser) {
|
||||
@@ -217,6 +228,7 @@ export const RestoreBackup = ({
|
||||
databaseName: databaseType === "web-server" ? "dokploy" : "",
|
||||
databaseType:
|
||||
backupType === "compose" ? ("postgres" as DatabaseType) : databaseType,
|
||||
backupType: backupType,
|
||||
metadata: {},
|
||||
},
|
||||
resolver: zodResolver(RestoreBackupSchema),
|
||||
@@ -559,7 +571,7 @@ export const RestoreBackup = ({
|
||||
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="serviceName"
|
||||
name="metadata.serviceName"
|
||||
render={({ field }) => (
|
||||
<FormItem className="w-full">
|
||||
<FormLabel>Service Name</FormLabel>
|
||||
|
||||
@@ -14,7 +14,13 @@ import {
|
||||
TooltipTrigger,
|
||||
} from "@/components/ui/tooltip";
|
||||
import { api } from "@/utils/api";
|
||||
import { Database, DatabaseBackup, Play, Trash2 } from "lucide-react";
|
||||
import {
|
||||
ClipboardList,
|
||||
Database,
|
||||
DatabaseBackup,
|
||||
Play,
|
||||
Trash2,
|
||||
} from "lucide-react";
|
||||
import Link from "next/link";
|
||||
import { useState } from "react";
|
||||
import { toast } from "sonner";
|
||||
@@ -29,6 +35,7 @@ import {
|
||||
PostgresqlIcon,
|
||||
} from "@/components/icons/data-tools-icons";
|
||||
import { AlertBlock } from "@/components/shared/alert-block";
|
||||
import { ShowSchedulesLogs } from "../../application/schedules/show-schedules-logs";
|
||||
|
||||
interface Props {
|
||||
id: string;
|
||||
@@ -156,6 +163,7 @@ export const ShowBackups = ({
|
||||
<RestoreBackup
|
||||
id={id}
|
||||
databaseType={databaseType}
|
||||
backupType={backupType}
|
||||
serverId={
|
||||
"serverId" in postgres ? postgres.serverId : undefined
|
||||
}
|
||||
@@ -267,6 +275,15 @@ export const ShowBackups = ({
|
||||
</div>
|
||||
|
||||
<div className="flex flex-row md:flex-col gap-1.5">
|
||||
<ShowSchedulesLogs deployments={backup.deployments}>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
className="size-8"
|
||||
>
|
||||
<ClipboardList className="size-4 transition-colors " />
|
||||
</Button>
|
||||
</ShowSchedulesLogs>
|
||||
<TooltipProvider delayDuration={0}>
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
|
||||
2
apps/dokploy/drizzle/0090_lame_gressill.sql
Normal file
2
apps/dokploy/drizzle/0090_lame_gressill.sql
Normal file
@@ -0,0 +1,2 @@
|
||||
ALTER TABLE "deployment" ADD COLUMN "backupId" text;--> statement-breakpoint
|
||||
ALTER TABLE "deployment" ADD CONSTRAINT "deployment_backupId_backup_backupId_fk" FOREIGN KEY ("backupId") REFERENCES "public"."backup"("backupId") ON DELETE cascade ON UPDATE no action;
|
||||
2
apps/dokploy/drizzle/0091_colossal_lifeguard.sql
Normal file
2
apps/dokploy/drizzle/0091_colossal_lifeguard.sql
Normal file
@@ -0,0 +1,2 @@
|
||||
ALTER TABLE "backup" ADD COLUMN "appName" text NOT NULL;--> statement-breakpoint
|
||||
ALTER TABLE "backup" ADD CONSTRAINT "backup_appName_unique" UNIQUE("appName");
|
||||
5683
apps/dokploy/drizzle/meta/0090_snapshot.json
Normal file
5683
apps/dokploy/drizzle/meta/0090_snapshot.json
Normal file
File diff suppressed because it is too large
Load Diff
5697
apps/dokploy/drizzle/meta/0091_snapshot.json
Normal file
5697
apps/dokploy/drizzle/meta/0091_snapshot.json
Normal file
File diff suppressed because it is too large
Load Diff
@@ -631,6 +631,20 @@
|
||||
"when": 1746287354535,
|
||||
"tag": "0089_eminent_winter_soldier",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 90,
|
||||
"version": "7",
|
||||
"when": 1746287994297,
|
||||
"tag": "0090_lame_gressill",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 91,
|
||||
"version": "7",
|
||||
"when": 1746289884571,
|
||||
"tag": "0091_colossal_lifeguard",
|
||||
"breakpoints": true
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -103,6 +103,7 @@ export const userRouter = createTRPCRouter({
|
||||
backups: {
|
||||
with: {
|
||||
destination: true,
|
||||
deployments: true,
|
||||
},
|
||||
},
|
||||
apiKeys: true,
|
||||
|
||||
Reference in New Issue
Block a user