MongoDB 4.0 备份恢复工具参数介绍

版权声明:本文为博主原创文章,转载请注明出处 https://blog.csdn.net/vkingnew/article/details/83061791
# ./mongo --version
MongoDB shell version v4.0.2
git version: fc1573ba18aee42f97a3bb13b67af7d837826b47
OpenSSL version: OpenSSL 1.0.1e-fips 11 Feb 2013
allocator: tcmalloc
modules: none
build environment:
    distmod: rhel70
    distarch: x86_64
    target_arch: x86_64

# ./mongodump --help
Usage:
  mongodump <options>

Export the content of a running server into .bson files.

Specify a database with -d and a collection with -c to only dump that database or collection.

See http://docs.mongodb.org/manual/reference/program/mongodump/ for more information.

general options:
      --help                                               打印工具的帮助信息
      --version                                            打印工具的版本并退出

verbosity options:
  -v, --verbose=<level>                                     更详细的日志输出(包括多次以获得更多详细信息,例如-vvvvv,或指定数值,例如--verbose = N)
      --quiet                                               隐藏所有日志输出

connection options:
  -h, --host=<hostname>                                     连接mongodb的主机,针对复制集的格式如下setname/host1,host2
      --port=<port>                                         mongodb服务器的端口 (也可以使用 --host hostname:port)

ssl options:
      --ssl                                                 连接到启用了ssl的mongod或mongos
      --sslCAFile=<filename>                                包含证书颁发机构的根证书链的.pem文件
      --sslPEMKeyFile=<filename>                            包含证书和密钥的.pem文件
      --sslPEMKeyPassword=<password>                        必要时,用于解密sslPEMKeyFile的密码
      --sslCRLFile=<filename>                               包含证书吊销列表的.pem文件
      --sslAllowInvalidCertificates                         绕过服务器证书的验证
      --sslAllowInvalidHostnames                            绕过服务器名称的验证
      --sslFIPSMode                                         使用已安装的openssl库的FIPS模式


authentication options:
  -u, --username=<username>                                 用于身份验证
  -p, --password=<password>                                 用于验证的密码
      --authenticationDatabase=<database-name>              保存用户凭据的数据库
      --authenticationMechanism=<mechanism>                 使用的身份验证机制

namespace options:
  -d, --db=<database-name>                                  使用的数据库
  -c, --collection=<collection-name>                        使用的集合

uri options:
      --uri=mongodb-uri                                     mongodb uri 连接串

query options:
  -q, --query=                                              查询过滤器,作为JSON字符串,比如 '{x:{$gt:1}}'
      --queryFile=                                          包含查询过滤器文件的路径(JSON)
      --readPreference=<string>|<json>                      指定首选项名称或首选项json对象
      --forceTableScan                                      强制进行表扫描

output options:
  -o, --out=<directory-path>                                输出目录,或' - '表示stdout(默认为'dump')
      --gzip                                                使用Gzip压缩归档我们的集合输出
      --repair                                              尝试从损坏的数据文件中恢复文档(并非所有存储引擎都支持)
      --oplog                                               使用oplog获取时间点(point-in-time)快照
      --archive=<file-path>                                 转储为指定路径的存档。 如果指定了flag而没有值,则将归档存储到stdout
      --dumpDbUsersAndRoles                                 备份数据库中的用户名和数据库角色
      --excludeCollection=<collection-name>                 从转储中排除的集合(可以多次指定以排除其他集合)
      --excludeCollectionsWithPrefix=<collection-prefix>    转储中排除具有给定前缀的所有集合(可以多次指定以排除其他前缀)
  -j, --numParallelCollections=                             并行备份的线程数默认是4 (default: 4)
      --viewsAsCollections                                  将视图转储为普通集合,省略标准集合
	  

# ./mongorestore --help
Usage:
  mongorestore <options> <directory or file to restore>

Restore backups generated with mongodump to a running server.

Specify a database with -d to restore a single database from the target directory,
or use -d and -c to restore a single collection from a single .bson file.

See http://docs.mongodb.org/manual/reference/program/mongorestore/ for more information.

general options:
      --help                                                print usage
      --version                                             print the tool version and exit

verbosity options:
  -v, --verbose=<level>                                     more detailed log output (include multiple times for more verbosity, e.g. -vvvvv, or specify a numeric value,
                                                            e.g. --verbose=N)
      --quiet                                               hide all log output

connection options:
  -h, --host=<hostname>                                     mongodb host to connect to (setname/host1,host2 for replica sets)
      --port=<port>                                         server port (can also use --host hostname:port)

ssl options:
      --ssl                                                 connect to a mongod or mongos that has ssl enabled
      --sslCAFile=<filename>                                the .pem file containing the root certificate chain from the certificate authority
      --sslPEMKeyFile=<filename>                            the .pem file containing the certificate and key
      --sslPEMKeyPassword=<password>                        the password to decrypt the sslPEMKeyFile, if necessary
      --sslCRLFile=<filename>                               the .pem file containing the certificate revocation list
      --sslAllowInvalidCertificates                         bypass the validation for server certificates
      --sslAllowInvalidHostnames                            bypass the validation for server name
      --sslFIPSMode                                         use FIPS mode of the installed openssl library

authentication options:
  -u, --username=<username>                                 username for authentication
  -p, --password=<password>                                 password for authentication
      --authenticationDatabase=<database-name>              database that holds the user's credentials
      --authenticationMechanism=<mechanism>                 authentication mechanism to use

uri options:
      --uri=mongodb-uri                                     mongodb uri connection string

namespace options:
  -d, --db=<database-name>                                  从BSON文件恢复时指定的数据库
  -c, --collection=<collection-name>                        从BSON文件恢复的集合
      --excludeCollection=<collection-name>                 过时的参数.在恢复期间跳过的集合(可以多次指定以排除其他集合).
      --excludeCollectionsWithPrefix=<collection-prefix>    过时的参数.在恢复期间跳过具有给定前缀的集合(可以多次指定以排除其他前缀).
      --nsExclude=<namespace-pattern>                       排除匹配的命名空间
      --nsInclude=<namespace-pattern>                       包括匹配的命名空间
      --nsFrom=<namespace-pattern>                          重命名匹配的命名空间,必须具有匹配的nsTo
      --nsTo=<namespace-pattern>                            重命名匹配的命名空间,必须具有匹配的nsFrom

input options:
      --objcheck                                            插入前验证所有对象
      --oplogReplay                                         重放oplog以进行时间点恢复
      --oplogLimit=<seconds>[:ordinal]                      仅在提供的时间戳之前包含oplog条目
      --oplogFile=<filename>                                用于重放oplog的oplog文件
      --archive=<filename>                                  从指定的归档文件恢复转储;若指定了flag而没有值,则从stdin读取归档文件
      --restoreDbUsersAndRoles                              恢复给定数据库的用户和角色定义
      --dir=<directory-name>                                输入目录,对stdin使用' - '
      --gzip                                                解压缩gzip压缩输入

restore options:
      --drop                                                在导入之前删除每个集合
      --dryRun                                              查看摘要而不导入任何内容 建议详细说明
      --writeConcern=<write-concern>                        写关注选项比如 --writeConcern majority, --writeConcern '{w: 3, wtimeout: 500, fsync: true, j: true}'
      --noIndexRestore                                      不要恢复索引
      --noOptionsRestore                                    不恢复收集选项
      --keepIndexVersion                                    不要更新索引版本
      --maintainInsertionOrder                              在恢复期间保留文件的顺序
  -j, --numParallelCollections=                             要并行恢复的集合数默认为4
      --numInsertionWorkersPerCollection=                   每个集合并发运行的插入操作数(默认为1)
      --stopOnError                                         如果在插入时遇到错误则停止恢复(默认情况下关闭)
      --bypassDocumentValidation                            绕过文档验证
      --preserveUUID                                        保留原始集合UUID(默认情况下关闭,需要删除)
	  
# ./mongoimport --help
Usage:
  mongoimport <options> <file>

Import CSV, TSV or JSON data into MongoDB. If no file is provided, mongoimport reads from stdin.

See http://docs.mongodb.org/manual/reference/program/mongoimport/ for more information.

general options:
      --help                                      print usage
      --version                                   print the tool version and exit

verbosity options:
  -v, --verbose=<level>                           more detailed log output (include multiple times for more verbosity, e.g. -vvvvv, or specify a numeric value, e.g.
                                                  --verbose=N)
      --quiet                                     hide all log output

connection options:
  -h, --host=<hostname>                           mongodb host to connect to (setname/host1,host2 for replica sets)
      --port=<port>                               server port (can also use --host hostname:port)

ssl options:
      --ssl                                       connect to a mongod or mongos that has ssl enabled
      --sslCAFile=<filename>                      the .pem file containing the root certificate chain from the certificate authority
      --sslPEMKeyFile=<filename>                  the .pem file containing the certificate and key
      --sslPEMKeyPassword=<password>              the password to decrypt the sslPEMKeyFile, if necessary
      --sslCRLFile=<filename>                     the .pem file containing the certificate revocation list
      --sslAllowInvalidCertificates               bypass the validation for server certificates
      --sslAllowInvalidHostnames                  bypass the validation for server name
      --sslFIPSMode                               use FIPS mode of the installed openssl library

authentication options:
  -u, --username=<username>                       username for authentication
  -p, --password=<password>                       password for authentication
      --authenticationDatabase=<database-name>    database that holds the user's credentials
      --authenticationMechanism=<mechanism>       authentication mechanism to use

namespace options:
  -d, --db=<database-name>                        database to use
  -c, --collection=<collection-name>              collection to use

uri options:
      --uri=mongodb-uri                           mongodb uri connection string

input options:
  -f, --fields=<field>[,<field>]*                 逗号分隔的字段列表, e.g. -f name,age
      --fieldFile=<filename>                      带有字段名称的文件 - 每行1个
      --file=<filename>                           要导入的文件; 如果未指定,则使用stdin
      --headerline                                使用输入源中的第一行作为字段列表(仅限CSV和TSV)
      --jsonArray                                 将输入源视为JSON数组
      --parseGrace=<grace>                        当类型强制失败时控制行为,可选项有: autoCast, skipField, skipRow, stop (defaults to 'stop') 
      --type=<type>                               要导入的输入格式:json, csv, or tsv (defaults to 'json') 
      --columnsHaveTypes                          表明字段列表(来自--fields,--fieldsFile或--headerline)指定类型; 它们必须采用'<colName>.<type>(<arg>)'的形式. 类型可以是以下之一:auto,binary,bool,date,date_go,date_ms,date_oracle,double,int32,int64,string。
                                                   对于每种日期类型,参数是日期时间布局字符串;对于二进制类型,参数可以是以下之一:base32,base64,hex. 所有其他类型都采用空参数;仅对CSV和TSV导入有效,例如zipcode.string(), thumbnail.binary(base64)
                                                  

ingest options:
      --drop                                      在插入文档之前删除集合
      --ignoreBlanks                              忽略CSV和TSV中具有空值的字段
      --maintainInsertionOrder                    按照输出出现的顺序插入文档
  -j, --numInsertionWorkers=<number>              并发运行的插入操作数,默认为1
      --stopOnError                               在第一次insert/ upsert错误时停止导入
      --mode=[insert|upsert|merge]                insert:仅插入;upsert:插入或替换现有文档;merge:插入或修改现有文档。 默认为insert
      --upsertFields=<field>[,<field>]*           当--mode设置为upsert或merge时,查询部分的逗号分隔字段
      --writeConcern=<write-concern-specifier>    写关注选项e.g. --writeConcern majority, --writeConcern '{w: 3, wtimeout: 500, fsync: true, j: true}'
      --bypassDocumentValidation                  绕过文档验证

# ./mongoexport --help
Usage:
  mongoexport <options>

Export data from MongoDB in CSV or JSON format.

See http://docs.mongodb.org/manual/reference/program/mongoexport/ for more information.

general options:
      --help                                      print usage
      --version                                   print the tool version and exit

verbosity options:
  -v, --verbose=<level>                           more detailed log output (include multiple times for more verbosity, e.g. -vvvvv, or specify a numeric value, e.g.
                                                  --verbose=N)
      --quiet                                     hide all log output

connection options:
  -h, --host=<hostname>                           mongodb host to connect to (setname/host1,host2 for replica sets)
      --port=<port>                               server port (can also use --host hostname:port)

ssl options:
      --ssl                                       connect to a mongod or mongos that has ssl enabled
      --sslCAFile=<filename>                      the .pem file containing the root certificate chain from the certificate authority
      --sslPEMKeyFile=<filename>                  the .pem file containing the certificate and key
      --sslPEMKeyPassword=<password>              the password to decrypt the sslPEMKeyFile, if necessary
      --sslCRLFile=<filename>                     the .pem file containing the certificate revocation list
      --sslAllowInvalidCertificates               bypass the validation for server certificates
      --sslAllowInvalidHostnames                  bypass the validation for server name
      --sslFIPSMode                               use FIPS mode of the installed openssl library

authentication options:
  -u, --username=<username>                       username for authentication
  -p, --password=<password>                       password for authentication
      --authenticationDatabase=<database-name>    database that holds the user's credentials
      --authenticationMechanism=<mechanism>       authentication mechanism to use

namespace options:
  -d, --db=<database-name>                        database to use
  -c, --collection=<collection-name>              collection to use

uri options:
      --uri=mongodb-uri                           mongodb uri connection string

output options:
  -f, --fields=<field>[,<field>]*                 逗号分隔的字段名称列表(导出CSV时需要) e.g. -f "name,age"
      --fieldFile=<filename>                      带有字段名称的文件 - 每行1个
      --type=<type>                               输出格式,json或csv(默认为'json')
  -o, --out=<filename>                            输出文件; 如果未指定,则使用stdout
      --jsonArray                                 输出到JSON数组而不是每行一个对象
      --pretty                                    输出为易于阅读的JSON格式
      --noHeaderLine                              导出第一行没有字段名称列表的CSV数据

querying options:
  -q, --query=<json>                              查询过滤器,作为JSON字符串,例如'{x:{$ gt:1}}'
      --queryFile=<filename>                      包含查询过滤器(JSON)的文件的路径
  -k, --slaveOk                                   允许第二次读取
      --readPreference=<string>|<json>            指定首选项名称或首选项json对象
      --forceTableScan                            强制表扫描(不使用$snapshot)
      --skip=<count>                              要跳过的文件数量
      --limit=<count>                             限制要导出的文档数
      --sort=<json>                               作为json字符串用于排序,比如'{x:1}'
      --assertExists                              默认false,若指定若集合不存在将导出失败.
# ./bsondump --help
Usage:
  bsondump <options> <file>

View and debug .bson files.

See http://docs.mongodb.org/manual/reference/program/bsondump/ for more information.

general options:
      --help               print usage
      --version            print the tool version and exit

verbosity options:
  -v, --verbose=<level>    more detailed log output (include multiple times for more verbosity, e.g. -vvvvv, or specify a numeric value, e.g. --verbose=N)
      --quiet              hide all log output

output options:
      --type=<type>        输出类型:debug, json(默认值)
      --objcheck           在处理的过程中验证BSON.
      --pretty             美化输出JSON,便于阅读.
      --bsonFile=          转储到JSON的BSON文件的路径;默认值为stdin
      --outFile=           文件的路径转储到BSON;默认值为stdout	  

猜你喜欢

转载自blog.csdn.net/vkingnew/article/details/83061791