MongoDB的数据恢复工具 mongorestore
查看test库中的表
- > show collections
- system.indexes
- User
删除user表
- > db.user.drop();
- True
- > show collections
- System.indexes
现在利用mongorestore表恢复刚才利用 mongodump备份的数据
- [falcon@www.fwphp.cn ~/mongodb/bin]$ ./mongorestore --help
- usage: ./mongorestore [options] [directory or filename to restore from]
- options:
- --help produce help message
- -h [ --host ] arg mongo host to connect to
- -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 this path,
- instead of connecting to a mongod instance
- -v [ --verbose ] be more verbose (include multiple times for more
- verbosity e.g. -vvvvv)
- [falcon@www.fwphp.cn ~/mongodb/bin]$ ./mongorestore -d test -c user test/test/user.bson
- connected to: 127.0.0.1
- test/test/user.bson
- going into namespace [test.user]
- 100000 objects
User表中的10w条记录已经恢复
- > show collections
- system.indexes
- user
- > db.user.find();
- { "_id" : ObjectId("4b9c8db08ead0e3347000000"), "uid" : 1, "username" : "Falcon.C-1" }
- { "_id" : ObjectId("4b9c8db08ead0e3347010000"), "uid" : 2, "username" : "Falcon.C-2" }
- { "_id" : ObjectId("4b9c8db08ead0e3347020000"), "uid" : 3, "username" : "Falcon.C-3" }
- { "_id" : ObjectId("4b9c8db08ead0e3347030000"), "uid" : 4, "username" : "Falcon.C-4" }
- { "_id" : ObjectId("4b9c8db08ead0e3347040000"), "uid" : 5, "username" : "Falcon.C-5" }
- .................
- has more
默认的访问端口 是28017
