Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Mongodb backup and recovery

2025-01-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

1. Backup of the whole database:

Mongodump-h dbhost-d dbname-o dbdirectory

-the address of the server where the h:MongDB is located, for example: 127.0.0.1. Of course, you can also specify the port number: 127.0.0.1 27017.

-d: database instance that needs to be backed up, for example: test

-o: the location of the backup data, for example: C:\ data\ dump. Of course, this directory needs to be established in advance. After the backup is completed, the system automatically creates a test directory under the dump directory, in which the backup data of the database instance is stored.

2. Recovery of the whole library:

Mongorestore-h dbhost-d dbname-directoryperdb dbdirectory

Mongorestore-h dbhost-d dbname c:\ xxx

-address of the server where the h:MongoDB is located

-d: the database instance to be restored, such as test. Of course, this name can also be different from that of backup, such as test2.

-directoryperdb: where the backup data is located, for example: C:\ data\ dump\ test. Why add an extra test instead of the dump at the time of backup? check the tips for yourself!

-drop: when restoring, delete the current data first, and then restore the backed-up data. That is to say, after recovery, the data added and modified after backup will be deleted, so use it with caution.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report