Backup and recovery are required for any database, which is of much importance and everyone understands. MongoDB also provides backup and recovery functions, which are under the MongoDB download directory.
Backup and recovery are required for any database, which is of much importance and everyone understands. MongoDB also provides backup and recovery functions, which are under the MongoDB download directory.
Backup and recovery are required for any database. The importance of backup and recovery is not enough.
Mongodbalso describes the functions of tracing and restoration, which are the mongdump.exeand mongorestore.exe files downloaded by mongodb.
First, let's talk about the Syntax:
Backup:
> Mongodump-h dbhost-d dbname-o dbdirectory
-H: the address of the MongDB server, such as 127.0.0.1. You can also specify the port number 127.0.0.1: 27017.
-D: The database instance to be backed up, for example, test
-O: The storage location of the backup data, for example, c: \ data \ dump. Of course, this directory must be created in advance. After the backup is complete, the system automatically creates a test directory under the dump directory, which stores the backup data of the database instance.
Instance:> mongodump-h 127.0.0.1-d test-o c: \ data \ dump \
Recovery:
> Mongorestore-h dbhost-d dbname -- directoryperdb dbdirectory
-H: Address of the MongoDB Server
-D: The database instance to be restored, for example, test. Of course, this name can be different from that during backup, for example, test2.
-- Directoryperdb: the location where the backup data is located, for example, c: \ data \ dump \ test. Why should we add another test instead of dump during Backup? Read the prompt on your own!
-- Drop: Delete the current data and restore the backup data. That is to say, after the restoration, all the data added and modified after the backup will be deleted and used with caution!
Instance:> mongorestore-h 127.0.0.1-d test -- directoryperdb c: \ data \ dump \ test
MongoDB details: click here
MongoDB: click here
Related reading:
MongoDB backup and recovery
CentOS compilation and installation of MongoDB
CentOS compilation and installation of php extensions for MongoDB and mongoDB
CentOS 6 install MongoDB and server configuration using yum
Install MongoDB2.4.3 in Ubuntu 13.04
How to create a new database and set in MongoDB
MongoDB beginners must read (both concepts and practices)
MongoDB authoritative Guide (The Definitive Guide) in English [PDF]