MongoDB - Create Backup
MongoDB - Create Backup : the way to create a backup in MongoDB.
Dump MongoDB DataTo create backup of database in MongoDB, you ought to use mongodump command. This command will dump the entire information of your server into the dump listing.
There are many options to be had by which you can restriction the amount of records or create backup of your remote server.
SyntaxThere are following simple syntax of mongodump command :
ExampleStart your mongod server. Assuming that your mongod server is strolling on the localhost and port eighty,open a command set off and go to the bin directory of your mongodb example and kind the command mongodump Consider the mycol series has the subsequent records.
>mongodumpThe command will connect with the server going for walks at 127.0.0.1 and port 80 and returned all records of the server to directory /bin/dump/.
Following is a listing of available options that may be used with the mongodump command.
|mongodump --host HOST_NAME --port PORT_NUMBER||This commmand will backup all databases of special mongod instance.||mongodump --host tutorialspoint.Com --port 27017|
|mongodump --dbpath DB_PATH --out BACKUP_DIRECTORY||This command will backup simplest unique database at exact course.||mongodump --dbpath /facts/db/ --out /records/backup/|
|mongodump --collection COLLECTION --db DB_NAME||This command will backup simplest precise collection of certain database.||mongodump --collection mycol --db test|
Restore statisticsTo repair backup information MongoDB's mongorestore command is used. This command restores all of the information from the backup listing.
SyntaxThe primary syntax of mongorestore command is −