-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
support custom file name in gitea dump command
#6474
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,6 +12,7 @@ import ( | |
| "os" | ||
| "path" | ||
| "path/filepath" | ||
| "strings" | ||
| "time" | ||
|
|
||
| "code.gitea.io/gitea/models" | ||
|
|
@@ -35,6 +36,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: "gitea-dump-%d.zip", | ||
| Usage: "Name of the dump file which will be created.", | ||
| }, | ||
| cli.BoolFlag{ | ||
| Name: "verbose, v", | ||
| Usage: "Show process details", | ||
|
|
@@ -85,7 +91,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 := getDumpFileName(ctx) | ||
| log.Printf("Packing dump files...") | ||
| z, err := zip.Create(fileName) | ||
| if err != nil { | ||
|
|
@@ -164,6 +170,16 @@ func runDump(ctx *cli.Context) error { | |
| return nil | ||
| } | ||
|
|
||
| func getDumpFileName(ctx *cli.Context) string { | ||
| fmtString := ctx.String("file") | ||
|
|
||
| if strings.Count(fmtString, "%d") > 0 { | ||
| fmtString = fmt.Sprintf(fmtString, time.Now().Unix()) | ||
|
||
| } | ||
|
|
||
| return fmtString | ||
| } | ||
|
|
||
| // zipAddDirectoryExclude zips absPath to specified zipPath inside z excluding excludeAbsPath | ||
| func zipAddDirectoryExclude(zip *zip.ZipArchive, zipPath, absPath string, excludeAbsPath string) error { | ||
| absPath, err := filepath.Abs(absPath) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.