惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
Schneier on Security
L
LangChain Blog
博客园 - Franky
Microsoft Security Blog
Microsoft Security Blog
M
MIT News - Artificial intelligence
月光博客
月光博客
云风的 BLOG
云风的 BLOG
MongoDB | Blog
MongoDB | Blog
量子位
AWS News Blog
AWS News Blog
Jina AI
Jina AI
Webroot Blog
Webroot Blog
L
Lohrmann on Cybersecurity
Cisco Talos Blog
Cisco Talos Blog
Latest news
Latest news
Y
Y Combinator Blog
The GitHub Blog
The GitHub Blog
NISL@THU
NISL@THU
The Register - Security
The Register - Security
美团技术团队
博客园 - 三生石上(FineUI控件)
I
Intezer
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
N
Netflix TechBlog - Medium
H
Hackread – Cybersecurity News, Data Breaches, AI and More
T
The Exploit Database - CXSecurity.com
C
Cisco Blogs
Attack and Defense Labs
Attack and Defense Labs
S
Securelist
Know Your Adversary
Know Your Adversary
MyScale Blog
MyScale Blog
C
CERT Recently Published Vulnerability Notes
D
Darknet – Hacking Tools, Hacker News & Cyber Security
U
Unit 42
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
雷峰网
雷峰网
B
Blog
P
Privacy International News Feed
W
WeLiveSecurity
T
Threatpost
P
Palo Alto Networks Blog
O
OpenAI News
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
博客园_首页
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Forbes - Security
Forbes - Security
K
Kaspersky official blog
Recent Announcements
Recent Announcements
A
About on SuperTechFans
B
Blog RSS Feed

博客园 - K!ngZ

常用正则 MongoDB学习笔记(9)--优化器 profile MongoDB学习笔记(8)--索引及优化索引 MongoDB学习笔记(7)--访问控制 MongoDB学习笔记(5)--数据导入导出mongoexport MongoDB学习笔记(4)--Capped Collection MongoDB学习笔记(3)--高级查询 MongoDB学习笔记(2)--增删改查 MongoDB学习笔记(1)--了解MongoDB 远程文件抓取类 [转]BizTalk开发系列(三十四) Xpath SQL Server 2005 命令行实用工具 [转]雅虎公司C#笔试题 [转] OLE DB 访问接口 "SQLNCLI" 返回了消息 "未指定的错误"。 Asp.net中的日期处理函数 [转]正则表达式实现资料验证的技术总结 ajax乱码问题解决 [转]ASP.Net缓存总结 [转]预防按钮的多次点击【恶意刷新】
MongoDB学习笔记(6)--数据备份数据恢复
K!ngZ · 2011-09-14 · via 博客园 - K!ngZ

可以用mongodump来做MongoDB 的库或表级别的备份,下面举例说明:
备份my_mongodb数据库

[root@localhost bin]# ./mongodump -d my_mongodb
connected to: 127.0.0.1
DATABASE: my_mongodb     to     dump/my_mongodb
        my_mongodb.system.indexes to dump/my_mongodb/system.indexes.bson
                 1 objects
        my_mongodb.user to dump/my_mongodb/user.bson
                 2 objects
[root@localhost bin]# ll
总计 67648
-rwxr-xr-x 1 root root 7508756 2011-04-06 bsondump
drwxr-xr-x 3 root root    4096 04-10 23:54 dump
-rwxr-xr-x 1 root root 2978016 2011-04-06 mongo

此时会在当前目录下创建一个 dump目录,用于存放备份出来的文件 也可以指定备份存放的目录,

 [root@localhost bin]# ./mongodump -d my_mongodb -o my_mongodb_dump

connected to: 127.0.0.1
DATABASE: my_mongodb     to     my_mongodb_dump/my_mongodb
        my_mongodb.system.indexes
my_mongodb_dump/my_mongodb/system.indexes.bson
                 1 objects
        my_mongodb.user to my_mongodb_dump/my_mongodb/user.bson
                 2 objects
[root@localhost bin]#

 

数据恢复

[root@localhost bin]# ./mongorestore -d my_mongodb my_mongodb_dump/*
connected to: 127.0.0.1
Wed Apr 11 00:03:03 my_mongodb_dump/my_mongodb/user .bson
Wed Apr 11 00:03:03      going into namespace [my_mongodb.user]
Wed Apr 11 00:03:03      2 objects found
Wed Apr 11 00:03:03 my_mongodb_dump/my_mongodb/system.indexes.bson
Wed Apr 11 00:03:03      going into namespace [my_mongodb.system.indexes]
Wed Apr 11 00:03:03 { name: "_id_", ns: "my_mongodb.user", key: { _id: 1 }, v: 0 }
Wed Apr 11 00:03:03      1 objects found
[root@localhost bin]#