Backup of the data is very much in the two ways, of course, you can also take advantage of the snapshot:
---------------------------------------------------------------------
One, direct copy data file Mode backup restore
----------------------------------------------------------------------
Note: When calling the Db.fsyncunlock () and Db.fsynclock () commands, do not close the shell, because if you enable authentication or disconnect the link, you may not be able to connect, and you will need to restart the Mongod, these commands will be invalidated.
1. Lock the database: Db.fsynclock ()
This command disables all writes and writes dirty pages to disk to ensure that the data no longer changes. This time the write operation will be queued in memory until the database is unlocked.
2.mkdir/mongodbback/zou
Cp-r/server/mongo/data/*/mongodbback/zou
3. Unlocking the Database Db.fsyncunlock ()
After the backup is complete, then how to reply?
4. Cp-r/mongodb/zou/*/server/mongo/data/
Attention:
You should ensure that Mongod is not running and/server/mongo/data/is empty before you restore.
Be sure to confirm that the CP command executed successfully before deleting it.
After the restore is complete, start mongod again.
Start Mongod Use the command: mongod-f/etc/mongod.conf--fork--nojournal
-----------------------------------------------------------------------------
Second, mongodump backup
-----------------------------------------------------------------------------
1. Database Mongod Backup in a state that is not running
Mongodump--dbpath/server/mongo/data/--out/backup/zou/mongo
Restore when the database is not started
Mongorestore--dbpath/backup/zou/mongo/--journal/server/mongo/data
If you want to specify a backup restore a specific database by specifying the name of the database folder under File path
2. Remote link for backup
Mongodump--host www.zou.com--port 27017--username Zou--password 123.com--out/backup/zou/mongo/mongodump-2016-03-11
Recovery
Mongodump--host www.zou.com--port 27017--username Zou--password 123.com/backup/zou/mongo/mongodump-2016-03-11
3. Using Oplog for backup
Mongodump is not a snapshot backup, and the system may continue to operate during the backup process.
The Oplog setting is to prevent this from happening, but the premise of using Oplog is that the--replset option is used Mongod startup
Backup and restore same as 2, except with--oplog and Oplogreplay parameters
This article is from the "Arctic Linux" blog, be sure to keep this source http://941012521.blog.51cto.com/9253690/1749991
MongoDB Backup and restore