From a089292461aef0038b844c6db53c29b887bc14fb Mon Sep 17 00:00:00 2001 From: goodbest Date: Thu, 2 Apr 2015 10:18:59 +0800 Subject: [PATCH 1/2] fix restore/backup bug: mongo -port to --port --- app/service/ConfigService.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/service/ConfigService.go b/app/service/ConfigService.go index 1d9d686..98973b3 100644 --- a/app/service/ConfigService.go +++ b/app/service/ConfigService.go @@ -305,7 +305,7 @@ func (this *ConfigService) Backup(remark string) (ok bool, msg string) { username, _ := revel.Config.String("db.username") password, _ := revel.Config.String("db.password") // mongodump -h localhost -d leanote -o /root/mongodb_backup/leanote-9-22/ -u leanote -p nKFAkxKnWkEQy8Vv2LlM - binPath = binPath + " -h " + host + " -d " + dbname + " -port " + port + binPath = binPath + " -h " + host + " -d " + dbname + " --port " + port if username != "" { binPath += " -u " + username + " -p " + password } @@ -361,7 +361,7 @@ func (this *ConfigService) Restore(createdTime string) (ok bool, msg string) { username, _ := revel.Config.String("db.username") password, _ := revel.Config.String("db.password") // mongorestore -h localhost -d leanote -o /root/mongodb_backup/leanote-9-22/ -u leanote -p nKFAkxKnWkEQy8Vv2LlM - binPath = binPath + " --drop -h " + host + " -d " + dbname + " -port " + port + binPath = binPath + " --drop -h " + host + " -d " + dbname + " --port " + port if username != "" { binPath += " -u " + username + " -p " + password } From 68eaac9622eab3b8d37585792576c93c771976a7 Mon Sep 17 00:00:00 2001 From: goodbest Date: Thu, 2 Apr 2015 10:43:46 +0800 Subject: [PATCH 2/2] mongo3 dont't have --directoryperdb option; Just append dumpPath by the end of the command is capable for both mongo2 and 3 --- app/service/ConfigService.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/service/ConfigService.go b/app/service/ConfigService.go index 98973b3..9144ec2 100644 --- a/app/service/ConfigService.go +++ b/app/service/ConfigService.go @@ -372,7 +372,7 @@ func (this *ConfigService) Restore(createdTime string) (ok bool, msg string) { return false, path + " Is Not Exists" } - binPath += " --directoryperdb " + path + binPath += " " + path cmd := exec.Command("/bin/sh", "-c", binPath) Log(binPath);