@ -1,4 +1,5 @@
// Copyright 2014 The Gogs Authors. All rights reserved.
// Copyright 2016 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
@ -21,9 +22,9 @@ import (
// CmdDump represents the available dump sub-command.
var CmdDump = cli . Command {
Name : "dump" ,
Usage : "Dump G ogs files and database",
Usage : "Dump G itea files and database",
Description : ` Dump compresses all related files and database into zip file .
It can be used for backup and capture G ogs server image to send to maintainer ` ,
It can be used for backup and capture G itea server image to send to maintainer ` ,
Action : runDump ,
Flags : [ ] cli . Flag {
cli . StringFlag {
@ -55,14 +56,14 @@ func runDump(ctx *cli.Context) error {
if _ , err := os . Stat ( tmpDir ) ; os . IsNotExist ( err ) {
log . Fatalf ( "Path does not exist: %s" , tmpDir )
}
TmpWorkDir , err := ioutil . TempDir ( tmpDir , "g ogs -dump-")
TmpWorkDir , err := ioutil . TempDir ( tmpDir , "g itea -dump-")
if err != nil {
log . Fatalf ( "Fail to create tmp work directory: %v" , err )
}
log . Printf ( "Creating tmp work dir: %s" , TmpWorkDir )
reposDump := path . Join ( TmpWorkDir , "g ogs -repo.zip")
dbDump := path . Join ( TmpWorkDir , "g ogs -db.sql")
reposDump := path . Join ( TmpWorkDir , "g itea -repo.zip")
dbDump := path . Join ( TmpWorkDir , "g itea -db.sql")
log . Printf ( "Dumping local repositories...%s" , setting . RepoRootPath )
zip . Verbose = ctx . Bool ( "verbose" )
@ -75,18 +76,18 @@ func runDump(ctx *cli.Context) error {
log . Fatalf ( "Fail to dump database: %v" , err )
}
fileName := fmt . Sprintf ( "g ogs -dump-%d.zip", time . Now ( ) . Unix ( ) )
fileName := fmt . Sprintf ( "g itea -dump-%d.zip", time . Now ( ) . Unix ( ) )
log . Printf ( "Packing dump files..." )
z , err := zip . Create ( fileName )
if err != nil {
log . Fatalf ( "Fail to create %s: %v" , fileName , err )
}
if err := z . AddFile ( "g ogs -repo.zip", reposDump ) ; err != nil {
log . Fatalf ( "Fail to include g ogs -repo.zip: %v", err )
if err := z . AddFile ( "g itea -repo.zip", reposDump ) ; err != nil {
log . Fatalf ( "Fail to include g itea -repo.zip: %v", err )
}
if err := z . AddFile ( "g ogs -db.sql", dbDump ) ; err != nil {
log . Fatalf ( "Fail to include g ogs -db.sql: %v", err )
if err := z . AddFile ( "g itea -db.sql", dbDump ) ; err != nil {
log . Fatalf ( "Fail to include g itea -db.sql: %v", err )
}
customDir , err := os . Stat ( setting . CustomPath )
if err == nil && customDir . IsDir ( ) {