centos下mongodb3.2数据库的备份与恢复初步
2016-04-01 11:43
525 查看
数据库的备份
mongodump -h dbhost -d dbname -o dbdirectory-h MongDB所在服务器地址,在本地操作时服务器默认地址是127.0.0.1。
-d 需要备份的数据库实例。
-o 备份的数据存放位置,在该位置下会成与你实例为名的文件夹,在文件夹下有collection 的bson和json文件。
完成后可以输入mongodump查看
数据库的恢复
mongorestore -h dbhost -d dbname –dir dbdirectory-h mongodb所在服务器
-d 所需要备份的数据库实例
-dir 数据库备份的位置
– drop 先删除当前数据库的数据,然后恢复备份的数据
完成后输入mongorestore查看恢复信息
恢复的几点注意
mongorestore can create a new database or add data to an existing database. However, mongorestore performs inserts only and does not perform updates. That is, if restoring documents to an existing database and collection and existing documents have the same value _id field as the to-be-restored documents, mongorestore will not overwrite those documents.(mongorestore可以创建一个新的数据库或数据添加到现有的数据库。然而,mongorestore只执行插入和不执行更新。也就是说,如果恢复文件到现有的数据库,并收集和现有的文件具有相同的值_id字段作为要被恢复的文件,mongorestore不会覆盖那些文件。)mongorestore recreates indexes recorded by mongodump.(mongorestore会创建mongodump录索引。)
The data format used by mongodump from version 2.2 or later is incompatible with earlier versions of mongod. Do not use recent versions of mongodump to back up older data stores.(从2.2版本使用mongodump或更高版本的数据格式是与早期版本的mongod不兼容。不要使用mongodump的最新版本的备份旧的数据存储。)
mongorestore does not restore the system.profile collection data; however, if the backup data includes system.profile collection data and the collection does not exist in the target database, mongorestore creates the collection but does not insert any data into the collection.(mongorestore不会恢复system.profile收集数据;然而,如果备份数据包括system.profile集合数据和集合未在目标数据库中存在,mongorestore创建集合,但不将任何数据插入到集合中。)
-
参考:
MongoDB 备份(mongodump)与恢复(mongorerstore)
mongorestore
相关文章推荐
- 分享微信开发Html5轻游戏中的几个坑
- 如何在 Fedora 上安装 MongoDB 服务器
- Centos6 编译安装Python
- PHP添加yaf xhprof mongodb 同理
- mongodb安装
- 硬盘安装CentOS 6.2以及添加GRUB启动菜单
- CentOS 6.2实战部署Nginx+MySQL+PHP
- 如何在 Ubuntu 上安装 MongoDB
- CentOS 7系统配置上的变化解析
- 信息安全聚合 Sec-News 的重构之路
- 路由器备份配置
- CentOS下DB2数据库安装过程详解
- 备份线路的配置
- CentOS 6.3下编译安装Ruby 2.0笔记
- perl操作MongoDB报错undefined symbol: HeUTF8解决方法
- 数据库备份 SQLServer的备份和灾难恢复
- 简化SQL Server备份与还原到云工作原理及操作方法
- 使用cgroups来限制MySQL企业备份服务对资源的占用