Browse Source

cmd/backup: able to specify archive name (#4320)

Added flag '--archive-name' for backup command.
pull/4343/head
Unknwon 8 years ago
parent
commit
8ce23e2c71
No known key found for this signature in database
GPG Key ID: 25B575AE3213B2B3
  1. 3
      cmd/backup.go

3
cmd/backup.go

@ -33,6 +33,7 @@ portable among all supported database engines.`,
boolFlag("verbose, v", "Show process details"), boolFlag("verbose, v", "Show process details"),
stringFlag("tempdir, t", os.TempDir(), "Temporary directory path"), stringFlag("tempdir, t", os.TempDir(), "Temporary directory path"),
stringFlag("target", "./", "Target directory path to save backup archive"), stringFlag("target", "./", "Target directory path to save backup archive"),
stringFlag("archive-name", fmt.Sprintf("gogs-backup-%d.zip", time.Now().Unix()), "Name of backup archive"),
boolFlag("database-only", "Only dump database"), boolFlag("database-only", "Only dump database"),
boolFlag("exclude-repos", "Exclude repositories"), boolFlag("exclude-repos", "Exclude repositories"),
}, },
@ -69,7 +70,7 @@ func runBackup(c *cli.Context) error {
log.Fatal(0, "Fail to save metadata '%s': %v", metaFile, err) log.Fatal(0, "Fail to save metadata '%s': %v", metaFile, err)
} }
archiveName := path.Join(c.String("target"), fmt.Sprintf("gogs-backup-%d.zip", time.Now().Unix())) archiveName := path.Join(c.String("target"), c.String("archive-name"))
log.Info("Packing backup files to: %s", archiveName) log.Info("Packing backup files to: %s", archiveName)
z, err := zip.Create(archiveName) z, err := zip.Create(archiveName)

Loading…
Cancel
Save