Create Backup in MongoDB
To create a database Backup in MongoDB, you should use the mongodump command. This command will dump all Server data into dump directory. There are many options available from which you can limit the amount of data or backup created by Remote Server.
The mongodump command in MongoDB
To create a database Backup in MongoDB, you should use the mongodump command. This command will dump all Server data into dump directory. There are many options available from which you can limit the amount of data or backup created by Remote Server.
Syntax
The basic syntax of the mongodump command in MongoDB is:
> mongodump
For example
Start Mongod Server. Suppose your server is running on locallhost and port 27017. Now, open a command prompt and go to the bin directory of Mongodb Instance, then compose the mongodump command.
You monitor the Collection named mycol with the following data:
> mongodump
This command will connect to the running Server at 127.0.0.1 and port 27017 and backup the entire data of the Server to the / bin / dump directory . The result of this command is as follows:
Here are some available options that can be used with the mongodump command.
Syntax Description mongodump --host HOST_NAME --port PORT_NUMBER This command will back up all databases of the mongodump --host definedspoint.com --port instance 27017 mongodump --dbpath DB_PATH - out BACKUP_DIRECTORY This command only backs up the database specified in the given path. mongodump --dbpath / data / db / --out / data / backup / mongodump --collection COLLECTION --db DB_NAME This command only backs up the specified Collection of the database with the --collection mycol --db kiểm TRAData recovery in MongoDB
To restore backed up data in MongoDB, use the mongorestore command. This command restores all data from the backup folder.
Syntax
The basic syntax of the mongorestore command is:
> mongorestore
The result of the order is:
According to Tutorialspoint
Previous post: Shard in MongoDB
Next article: MongoDB Deployment
You should read it
- MongoDB queries and tasks you should know
- Index (Mong) in MongoDB
- Data type in MongoDB
- Map Reduce in MongoDB
- Instructions on 2 ways to install MongoDB on Raspberry Pi
- Advantages of MongoDB
- Shard in MongoDB
- Query Document in MongoDB
- ObjectId in MongoDB
- Text Search in MongoDB
- MongoDB malicious code attacks more than 26,000 victims in a week
- Data modeling in MongoDB