mirror of
https://github.com/tnb-labs/panel.git
synced 2026-08-29 02:10:58 +08:00
e8f7811aba
website create 未传网站类型导致必然失败,补全类型、代理地址、 数据库、备注等参数,并在进入 biz 层前统一走验证器校验。 新增命令: - firewall status/on/off/list/port - cert list/renew - restore panel - website cert/list,user create/delete - backup list,app list,cron list/run/status - database list-server 调整: - 密码取值改为参数 > ACEPANEL_PASSWORD > 交互输入(不回显) - 补 bind-domain/bind-ip/bind-ua 的 on 子命令 - 新增全局 --json,接入全部 list 命令 - port 支持 flag 写法,info 支持 -u 指定用户 - 位置参数命令补 ArgsUsage 修复: - cutoff clear 清理远程日志时目录与上传路径不一致,导致远程切割 日志从未被清理,ClearStorageExpired 改为接收目标目录 - restore 缺少 panel 分支,从 FixPanel 抽出 restorePanel 复用 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
143 lines
3.6 KiB
Go
143 lines
3.6 KiB
Go
package command
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/leonelquinteros/gotext"
|
|
"github.com/urfave/cli/v3"
|
|
|
|
"github.com/acepanel/panel/v3/internal/service"
|
|
)
|
|
|
|
// BackupCommand 数据备份命令组
|
|
func BackupCommand(t *gotext.Locale, cliService *service.CliService) *cli.Command {
|
|
|
|
return &cli.Command{
|
|
Name: "backup",
|
|
Usage: t.Get("Data backup"),
|
|
Commands: []*cli.Command{
|
|
{
|
|
Name: "list",
|
|
Usage: t.Get("List backup files"),
|
|
Flags: []cli.Flag{
|
|
&cli.StringFlag{
|
|
Name: "type",
|
|
Aliases: []string{"t"},
|
|
Usage: t.Get("Backup type (website, path, panel, mysql, postgresql, clickhouse, redis, valkey)"),
|
|
Required: true,
|
|
},
|
|
},
|
|
Action: func(ctx context.Context, cmd *cli.Command) error {
|
|
return cliService.BackupList(ctx, cmd)
|
|
},
|
|
},
|
|
{
|
|
Name: "website",
|
|
Usage: t.Get("Backup website"),
|
|
Flags: []cli.Flag{
|
|
&cli.StringFlag{
|
|
Name: "name",
|
|
Aliases: []string{"n"},
|
|
Usage: t.Get("Website name"),
|
|
Required: true,
|
|
},
|
|
&cli.UintFlag{
|
|
Name: "storage",
|
|
Aliases: []string{"s"},
|
|
Usage: t.Get("Storage ID (local storage if not filled)"),
|
|
},
|
|
},
|
|
Action: func(ctx context.Context, cmd *cli.Command) error {
|
|
return cliService.BackupWebsite(ctx, cmd)
|
|
},
|
|
},
|
|
{
|
|
Name: "database",
|
|
Usage: t.Get("Backup database"),
|
|
Flags: []cli.Flag{
|
|
&cli.StringFlag{
|
|
Name: "type",
|
|
Aliases: []string{"t"},
|
|
Usage: t.Get("Database type (mysql, postgresql, clickhouse, redis, valkey)"),
|
|
Required: true,
|
|
},
|
|
&cli.StringFlag{
|
|
Name: "name",
|
|
Aliases: []string{"n"},
|
|
Usage: t.Get("Database name"),
|
|
Required: true,
|
|
},
|
|
&cli.UintFlag{
|
|
Name: "storage",
|
|
Aliases: []string{"s"},
|
|
Usage: t.Get("Storage ID (local storage if not filled)"),
|
|
},
|
|
},
|
|
Action: func(ctx context.Context, cmd *cli.Command) error {
|
|
return cliService.BackupDatabase(ctx, cmd)
|
|
},
|
|
},
|
|
{
|
|
Name: "path",
|
|
Usage: t.Get("Backup directory"),
|
|
Flags: []cli.Flag{
|
|
&cli.StringFlag{
|
|
Name: "path",
|
|
Aliases: []string{"p"},
|
|
Usage: t.Get("Directory path"),
|
|
Required: true,
|
|
},
|
|
&cli.UintFlag{
|
|
Name: "storage",
|
|
Aliases: []string{"s"},
|
|
Usage: t.Get("Storage ID (local storage if not filled)"),
|
|
},
|
|
},
|
|
Action: func(ctx context.Context, cmd *cli.Command) error {
|
|
return cliService.BackupPath(ctx, cmd)
|
|
},
|
|
},
|
|
{
|
|
Name: "panel",
|
|
Usage: t.Get("Backup panel"),
|
|
Flags: []cli.Flag{},
|
|
Action: func(ctx context.Context, cmd *cli.Command) error {
|
|
return cliService.BackupPanel(ctx, cmd)
|
|
},
|
|
},
|
|
{
|
|
Name: "clear",
|
|
Usage: t.Get("Clear backups"),
|
|
Flags: []cli.Flag{
|
|
&cli.StringFlag{
|
|
Name: "type",
|
|
Aliases: []string{"t"},
|
|
Usage: t.Get("Backup type (website, path, mysql, postgresql, clickhouse, redis, valkey)"),
|
|
Required: true,
|
|
},
|
|
&cli.StringFlag{
|
|
Name: "file",
|
|
Aliases: []string{"f"},
|
|
Usage: t.Get("Backup file prefix"),
|
|
Required: true,
|
|
},
|
|
&cli.UintFlag{
|
|
Name: "keep",
|
|
Aliases: []string{"k"},
|
|
Usage: t.Get("Number of backups to keep"),
|
|
Required: true,
|
|
},
|
|
&cli.UintFlag{
|
|
Name: "storage",
|
|
Aliases: []string{"s"},
|
|
Usage: t.Get("Storage ID (local storage if not filled)"),
|
|
},
|
|
},
|
|
Action: func(ctx context.Context, cmd *cli.Command) error {
|
|
return cliService.BackupClear(ctx, cmd)
|
|
},
|
|
},
|
|
},
|
|
}
|
|
}
|