mongodb提供了两个命令来备份(mongodump )和恢复(mongorestore )数据库。
1.备份(mongodump )
用法 :
[root@web3 3]# mongodump –help
options:
–help produce help message
-v [ –verbose ] be more verbose (include multiple times for more
verbosity e.g. -vvvvv)
-h [ –host ] arg mongo host to connect to (“left,right” for pairs)
-d [ –db ] arg database to use
-c [ –collection ] arg collection to use (some commands)
-u [ –username ] arg username
-p [ –password ] arg password
–dbpath arg directly access mongod data files in the given path,
instead of connecting to a mongod instance - 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
-o [ –out ] arg (=dump) output directory