备份(mongodump):

      命令模板:

      mongodump -h 127.0.0.1 -d test -o c:\backup\mongoDb\data\%date:~0,4%-%date:~5,2%-%date:~8,2%\%time:~0,2%-%time:~3,2%

     C#代码:

        string strCmd = string.Format(
                  @"""{0}mongodump.exe"" -h 127.0.0.1 -d {1} -o {2}%date:~0,4%-%date:~5,2%-%date:~8,2%\%time:~0,2%-%time:~3,2%",
                  SysParameter.MongoDBPath,
                  SysParameter.Database,
                  SysParameter.MongoDBBackupPath);

恢复(mongorestore):

      命令模板:

     mongorestore -h 127.0.0.1 -d test c:\backup\mongoDb\data\2012-04-03\19-48\test

     C#代码:

          string strCmd = string.Format(
                    @"""{0}mongorestore.exe"" -h 127.0.0.1 -d {1} {2}{3}",
                    SysParameter.MongoDBPath,
                    SysParameter.Database,
                    SysParameter.MongoDBBackupPath,
                    SysParameter.Database);

 

相关文章:

  • 2021-12-13
  • 2022-01-02
  • 2021-12-07
  • 2021-10-13
  • 2021-08-01
  • 2021-12-01
  • 2022-02-04
  • 2021-11-23
猜你喜欢
  • 2021-05-01
  • 2022-12-23
  • 2022-12-23
  • 2022-01-21
  • 2021-11-30
  • 2021-12-06
相关资源
相似解决方案