Fix dump of log and custom directory in dump cmd
Now, the dump cmd uses setting.CustomPath and setting.LogRootPath instead of setting.WorkDir which was kind of broken if the gogs binary was in a different directory than gogs data. Additionally, the backup of setting.CustomPath directory is only done if it exists.release/v1.15
parent
c5a9be9115
commit
a59b1fcc21
10
cmd/dump.go
10
cmd/dump.go
|
@ -68,17 +68,21 @@ func runDump(ctx *cli.Context) {
|
|||
log.Fatalf("Fail to create %s: %v", fileName, err)
|
||||
}
|
||||
|
||||
workDir, _ := setting.WorkDir()
|
||||
if err := z.AddFile("gogs-repo.zip", reposDump); err !=nil {
|
||||
log.Fatalf("Fail to include gogs-repo.zip: %v", err)
|
||||
}
|
||||
if err := z.AddFile("gogs-db.sql", dbDump); err !=nil {
|
||||
log.Fatalf("Fail to include gogs-db.sql: %v", err)
|
||||
}
|
||||
if err := z.AddDir("custom", path.Join(workDir, "custom")); err !=nil {
|
||||
customDir, err := os.Stat(setting.CustomPath)
|
||||
if err == nil && customDir.IsDir() {
|
||||
if err := z.AddDir("custom", setting.CustomPath); err !=nil {
|
||||
log.Fatalf("Fail to include custom: %v", err)
|
||||
}
|
||||
if err := z.AddDir("log", path.Join(workDir, "log")); err !=nil {
|
||||
} else {
|
||||
log.Printf("Custom dir %s doesn't exist, skipped", setting.CustomPath)
|
||||
}
|
||||
if err := z.AddDir("log", setting.LogRootPath); err !=nil {
|
||||
log.Fatalf("Fail to include log: %v", err)
|
||||
}
|
||||
// FIXME: SSH key file.
|
||||
|
|
Loading…
Reference in New Issue