From dbba46c2161c673b7818b6602ea2fb4efffe224e Mon Sep 17 00:00:00 2001 From: glaszig Date: Mon, 1 Apr 2019 01:31:37 -0300 Subject: [PATCH] support custom file name in `gitea dump` command (#6474) * support custom file name in `gitea dump` command * simpler approach to handle default dump file name in `gitea dump` command --- cmd/dump.go | 7 ++++++- docs/content/doc/usage/command-line.md | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/cmd/dump.go b/cmd/dump.go index a89578529..5d450822f 100644 --- a/cmd/dump.go +++ b/cmd/dump.go @@ -35,6 +35,11 @@ It can be used for backup and capture Gitea server image to send to maintainer`, Value: "custom/conf/app.ini", Usage: "Custom configuration file path", }, + cli.StringFlag{ + Name: "file, f", + Value: fmt.Sprintf("gitea-dump-%d.zip", time.Now().Unix()), + Usage: "Name of the dump file which will be created.", + }, cli.BoolFlag{ Name: "verbose, v", Usage: "Show process details", @@ -85,7 +90,7 @@ func runDump(ctx *cli.Context) error { dbDump := path.Join(tmpWorkDir, "gitea-db.sql") - fileName := fmt.Sprintf("gitea-dump-%d.zip", time.Now().Unix()) + fileName := ctx.String("file") log.Printf("Packing dump files...") z, err := zip.Create(fileName) if err != nil { diff --git a/docs/content/doc/usage/command-line.md b/docs/content/doc/usage/command-line.md index 2e47b752e..510e90f95 100644 --- a/docs/content/doc/usage/command-line.md +++ b/docs/content/doc/usage/command-line.md @@ -148,6 +148,7 @@ in the current directory. - Options: - `--config path`, `-c path`: Gitea configuration file path. Optional. (default: custom/conf/app.ini). + - `--file name`, `-f name`: Name of the dump file with will be created. Optional. (default: gitea-dump-[timestamp].zip). - `--tempdir path`, `-t path`: Path to the temporary directory used. Optional. (default: /tmp). - `--skip-repository`, `-R`: Skip the repository dumping. Optional. - `--database`, `-d`: Specify the database SQL syntax. Optional.