/// <summary> /// 获得备份的配置 /// </summary> /// <param name="mongoDump"></param> /// <returns></returns> static public String GetMongodumpCommandLine(StruMongoDump mongoDump) { //mongodump.exe 备份程序 String dosCommand = @"mongodump -h @hostaddr:@port -d @dbname"; dosCommand = dosCommand.Replace("@hostaddr", mongoDump.HostAddr); dosCommand = dosCommand.Replace("@port", mongoDump.Port.ToString()); dosCommand = dosCommand.Replace("@dbname", mongoDump.DBName); if (mongoDump.CollectionName != String.Empty) { //-c CollectionName Or --collection CollectionName dosCommand += " --collection " + mongoDump.CollectionName; } if (mongoDump.OutPutPath != String.Empty) { //-o CollectionName Or --out CollectionName dosCommand += " --out \"" + mongoDump.OutPutPath + "\""; } return(dosCommand); }
/// <summary> /// 获得备份的配置 /// </summary> /// <param name="mongoDump"></param> /// <returns></returns> public static string GetMongodumpCommandLine(StruMongoDump mongoDump) { //mongodump.exe 备份程序 string dosCommand = @"mongodump -h @hostaddr:@port -d @dbname"; dosCommand = dosCommand.Replace("@hostaddr", mongoDump.HostAddr); dosCommand = dosCommand.Replace("@port", mongoDump.Port.ToString()); dosCommand = dosCommand.Replace("@dbname", mongoDump.DBName); if (mongoDump.CollectionName != string.Empty) { //-c CollectionName Or --collection CollectionName dosCommand += " --collection " + mongoDump.CollectionName; } if (mongoDump.OutPutPath != string.Empty) { //-o CollectionName Or --out CollectionName dosCommand += " --out " + mongoDump.OutPutPath; } return dosCommand; }