Skip to content

Commit dbba46c

Browse files
glaszigtechknowlogick
authored andcommitted
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
1 parent 2e1ead8 commit dbba46c

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

cmd/dump.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ It can be used for backup and capture Gitea server image to send to maintainer`,
3535
Value: "custom/conf/app.ini",
3636
Usage: "Custom configuration file path",
3737
},
38+
cli.StringFlag{
39+
Name: "file, f",
40+
Value: fmt.Sprintf("gitea-dump-%d.zip", time.Now().Unix()),
41+
Usage: "Name of the dump file which will be created.",
42+
},
3843
cli.BoolFlag{
3944
Name: "verbose, v",
4045
Usage: "Show process details",
@@ -85,7 +90,7 @@ func runDump(ctx *cli.Context) error {
8590

8691
dbDump := path.Join(tmpWorkDir, "gitea-db.sql")
8792

88-
fileName := fmt.Sprintf("gitea-dump-%d.zip", time.Now().Unix())
93+
fileName := ctx.String("file")
8994
log.Printf("Packing dump files...")
9095
z, err := zip.Create(fileName)
9196
if err != nil {

docs/content/doc/usage/command-line.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ in the current directory.
148148

149149
- Options:
150150
- `--config path`, `-c path`: Gitea configuration file path. Optional. (default: custom/conf/app.ini).
151+
- `--file name`, `-f name`: Name of the dump file with will be created. Optional. (default: gitea-dump-[timestamp].zip).
151152
- `--tempdir path`, `-t path`: Path to the temporary directory used. Optional. (default: /tmp).
152153
- `--skip-repository`, `-R`: Skip the repository dumping. Optional.
153154
- `--database`, `-d`: Specify the database SQL syntax. Optional.

0 commit comments

Comments
 (0)