【问题标题】:mongodb dump data to another directorymongodb 将数据转储到另一个目录
【发布时间】:2012-09-06 07:22:42
【问题描述】:

我知道我可以用这个通用转储数据

mongodump --db mydb

此命令会将所有 mydb 集合数据转储到 ./dump/mydb。但我想将数据转储到我命名的另一个目录(比如 /home/user/mydb)

我尝试过使用 --dbpath 和 --directoryperdb 选项,但这似乎不是我想要的

有没有办法做到这一点?

./mongodump --help

将 MongoDB 数据导出到 BSON 文件。

选项:

 --help                   produce help message
  -v [ --verbose ]         be more verbose (include multiple times for more
                           verbosity e.g. -vvvvv)
  --version                print the program's version and exit
  -h [ --host ] arg        mongo host to connect to ( <set name>/s1,s2 for
                           sets)
  --port arg               server port. Can also use --host hostname:port
  --ipv6                   enable IPv6 support (disabled by default)
  -u [ --username ] arg    username
  -p [ --password ] arg    password
  --dbpath arg             directly access mongod database files in the given
                           path, instead of connecting to a mongod  server -
                           needs to lock the data directory, so cannot be used
                           if a mongod is currently accessing the same path
  --directoryperdb         if dbpath specified, each db is in a separate
                           directory
  --journal                enable journaling
  -d [ --db ] arg          database to use
  -c [ --collection ] arg  collection to use (some commands)
  -o [ --out ] arg (=dump) output directory or "-" for stdout
  -q [ --query ] arg       json query
  --oplog                  Use oplog for point-in-time snapshotting
  --repair                 try to recover a crashed database
  --forceTableScan         force a table scan (do not use $snapshot) 

【问题讨论】:

    标签: mongodb


    【解决方案1】:

    你想要 -o 选项:

      -o [ --out ] arg (=dump) output directory or "-" for stdout
    

    这将让您指定输出的去向。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-07-21
      • 2015-12-24
      • 2014-07-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多