From 96b1df219904a9ee1d66c6d2c038f4174ff42c15 Mon Sep 17 00:00:00 2001 From: Mauricio Siu <47042324+Siumauricio@users.noreply.github.com> Date: Sun, 4 May 2025 03:31:51 -0600 Subject: [PATCH] Enhance backup scheduling interface and logging - Updated the backup scheduling form to include a tooltip explaining cron expression format and examples, improving user guidance. - Integrated a selection component for predefined cron expressions, allowing users to choose or enter custom schedules more easily. - Added logging for backup details in the server utility to aid in debugging and monitoring backup schedules. --- .../database/backups/handle-backup.tsx | 62 +++++++++++++++++-- packages/server/src/utils/backups/utils.ts | 3 + 2 files changed, 60 insertions(+), 5 deletions(-) diff --git a/apps/dokploy/components/dashboard/database/backups/handle-backup.tsx b/apps/dokploy/components/dashboard/database/backups/handle-backup.tsx index de5f2d3a..ca2cd27f 100644 --- a/apps/dokploy/components/dashboard/database/backups/handle-backup.tsx +++ b/apps/dokploy/components/dashboard/database/backups/handle-backup.tsx @@ -49,12 +49,19 @@ import { import { cn } from "@/lib/utils"; import { api } from "@/utils/api"; import { zodResolver } from "@hookform/resolvers/zod"; -import { DatabaseZap, PenBoxIcon, PlusIcon, RefreshCw } from "lucide-react"; +import { + DatabaseZap, + Info, + PenBoxIcon, + PlusIcon, + RefreshCw, +} from "lucide-react"; import { CheckIcon, ChevronsUpDown } from "lucide-react"; import { useEffect, useState } from "react"; import { useForm } from "react-hook-form"; import { toast } from "sonner"; import { z } from "zod"; +import { commonCronExpressions } from "../../application/schedules/handle-schedules"; type CacheType = "cache" | "fetch"; @@ -577,10 +584,55 @@ export const HandleBackup = ({ render={({ field }) => { return ( - Schedule (Cron) - - - + + Schedule + + + + + + +

+ Cron expression format: minute hour day month + weekday +

+

Example: 0 0 * * * (daily at midnight)

+
+
+
+
+
+ +
+ + + +
+
+ + Choose a predefined schedule or enter a custom cron + expression +
); diff --git a/packages/server/src/utils/backups/utils.ts b/packages/server/src/utils/backups/utils.ts index 0d4471f6..34f698e9 100644 --- a/packages/server/src/utils/backups/utils.ts +++ b/packages/server/src/utils/backups/utils.ts @@ -21,6 +21,9 @@ export const scheduleBackup = (backup: BackupSchedule) => { compose, } = backup; scheduleJob(backupId, schedule, async () => { + console.log("backup", backup); + console.log("databaseType", databaseType); + console.log("schedule", schedule); if (backup.backupType === "database") { if (databaseType === "postgres" && postgres) { await runPostgresBackup(postgres, backup);