備份前的檢查
> show dbs
MyDB 0.0625GB
admin (empty)
bruce 0.0625GB
local (empty)
test 0.0625GB
> use MyDB
switched to db MyDB
> db.users.find()
{ "_id" : ObjectId("4e290aa39a1945747b28f1ee"), "a" : 1, "b" : 1 }
{ "_id" : ObjectId("4e2cd2182a65c81f21566318"), "a" : 3, "b" : 5 }
>
整庫備份:
mongodump -h dbhost -d dbname -o dbdirectory
-h:MongDB所在服務器地址,例如:127.0.0.1,當然也可以指定端口號:127.0.0.1:27017
-d:需要備份的數據庫實例,例如:test
-o:備份的數據存放位置,例如:c:/data/dump,當然該目錄需要提前建立,在備份完成后,系統自動在dump目錄下建立一個test目錄,這個目錄里面存放該數據庫實例的備份數據。
mongodump的官方說明(可通過mongodump --help查看):options: --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 ( /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)
整庫恢復:
mongorestore -h dbhost -d dbname
主站蜘蛛池模板:
梁平县|
通化市|
台湾省|
武汉市|
宜川县|
墨江|
镇坪县|
渭南市|
珠海市|
新和县|
松桃|
青冈县|
突泉县|
闵行区|
冀州市|
五原县|
福泉市|
卓尼县|
潞城市|
左贡县|
庆云县|
池州市|
裕民县|
抚顺县|
周宁县|
万山特区|
平乡县|
海安县|
太康县|
徐闻县|
利川市|
宁明县|
盐源县|
从江县|
阿城市|
保山市|
辉县市|
九龙城区|
闽侯县|
来安县|
大英县|