diff options
author | Zsombor <gzsombor@users.noreply.github.com> | 2019-01-13 22:52:26 +0100 |
---|---|---|
committer | techknowlogick <hello@techknowlogick.com> | 2019-01-13 16:52:25 -0500 |
commit | 656456441ca09de27ffb44d7a8042db811ff989e (patch) | |
tree | a50a6ddb047b7314428fc66f747bd393c791272a /cmd/dump.go | |
parent | 5c44f751a30517914ad232607a1202111cf4f0fa (diff) | |
download | gitea-656456441ca09de27ffb44d7a8042db811ff989e.tar.gz gitea-656456441ca09de27ffb44d7a8042db811ff989e.zip |
Add flag to skip repository dumping (#5695)
Diffstat (limited to 'cmd/dump.go')
-rw-r--r-- | cmd/dump.go | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/cmd/dump.go b/cmd/dump.go index bbefda63ee..a895785295 100644 --- a/cmd/dump.go +++ b/cmd/dump.go @@ -48,6 +48,10 @@ It can be used for backup and capture Gitea server image to send to maintainer`, Name: "database, d", Usage: "Specify the database SQL syntax", }, + cli.BoolFlag{ + Name: "skip-repository, R", + Usage: "Skip the repository dumping", + }, }, } @@ -79,13 +83,27 @@ func runDump(ctx *cli.Context) error { os.Setenv("TMPDIR", tmpWorkDir) } - reposDump := path.Join(tmpWorkDir, "gitea-repo.zip") dbDump := path.Join(tmpWorkDir, "gitea-db.sql") - log.Printf("Dumping local repositories...%s", setting.RepoRootPath) + fileName := fmt.Sprintf("gitea-dump-%d.zip", time.Now().Unix()) + log.Printf("Packing dump files...") + z, err := zip.Create(fileName) + if err != nil { + log.Fatalf("Failed to create %s: %v", fileName, err) + } zip.Verbose = ctx.Bool("verbose") - if err := zip.PackTo(setting.RepoRootPath, reposDump, true); err != nil { - log.Fatalf("Failed to dump local repositories: %v", err) + + if ctx.IsSet("skip-repository") { + log.Printf("Skip dumping local repositories") + } else { + log.Printf("Dumping local repositories...%s", setting.RepoRootPath) + reposDump := path.Join(tmpWorkDir, "gitea-repo.zip") + if err := zip.PackTo(setting.RepoRootPath, reposDump, true); err != nil { + log.Fatalf("Failed to dump local repositories: %v", err) + } + if err := z.AddFile("gitea-repo.zip", reposDump); err != nil { + log.Fatalf("Failed to include gitea-repo.zip: %v", err) + } } targetDBType := ctx.String("database") @@ -99,16 +117,6 @@ func runDump(ctx *cli.Context) error { log.Fatalf("Failed to dump database: %v", err) } - fileName := fmt.Sprintf("gitea-dump-%d.zip", time.Now().Unix()) - log.Printf("Packing dump files...") - z, err := zip.Create(fileName) - if err != nil { - log.Fatalf("Failed to create %s: %v", fileName, err) - } - - if err := z.AddFile("gitea-repo.zip", reposDump); err != nil { - log.Fatalf("Failed to include gitea-repo.zip: %v", err) - } if err := z.AddFile("gitea-db.sql", dbDump); err != nil { log.Fatalf("Failed to include gitea-db.sql: %v", err) } |