备份
mongodump -hlocalhost -dmydb -cusers -q '{status:"A"}' -o /root/backup
删除数据
> db.users.remove({status:"A"})
WriteResult({ "nRemoved" : 3 })
恢复
[root@zabbix-bak ~]# mongorestore -hlocalhost -dmydb -cusers /root/backup/mydb/users.bson
2016-10-05T06:14:18.247+0800 checking for collection data in /root/backup/mydb/users.bson
2016-10-05T06:14:18.249+0800 reading metadata for mydb.users from /root/backup/mydb/users.metadata.json
2016-10-05T06:14:18.249+0800 restoring mydb.users from /root/backup/mydb/users.bson
2016-10-05T06:14:18.317+0800 restoring indexes for collection mydb.users from metadata
2016-10-05T06:14:18.317+0800 finished restoring mydb.users (3 documents)
2016-10-05T06:14:18.317+0800 done
[root@zabbix-bak ~]# mongodump -h 127.0.0.1 --port=27017 -uuser -p'pwd' -d mydb -c users -o /root/soft
2016-10-11T02:39:58.329+0000 writing mydb.users to
2016-10-11T02:40:01.329+0000 [##......................] mydb.users 1193358/11067438 (10.8%)
2016-10-11T02:40:04.329+0000 [#####...................] mydb.users 2430747/11067438 (22.0%)
2016-10-11T02:40:07.329+0000 [#######.................] mydb.users 3668173/11067438 (33.1%)
2016-10-11T02:40:10.329+0000 [##########..............] mydb.users 4846629/11067438 (43.8%)
2016-10-11T02:40:13.329+0000 [#############...........] mydb.users 6031815/11067438 (54.5%)
2016-10-11T02:40:16.329+0000 [###############.........] mydb.users 7254503/11067438 (65.5%)
2016-10-11T02:40:19.329+0000 [##################......] mydb.users 8484778/11067438 (76.7%)
2016-10-11T02:40:22.329+0000 [#####################...] mydb.users 9723043/11067438 (87.9%)
2016-10-11T02:40:25.329+0000 [#######################.] mydb.users 10962070/11067438 (99.0%)
2016-10-11T02:40:25.564+0000 [########################] mydb.users 11067463/11067438 (100.0%)
2016-10-11T02:40:25.564+0000 done dumping mydb.users (11067463 documents)
阅读(553) | 评论(0) | 转发(0) |