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

Backing up a single database through mongodump

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

-d the name of the database to be backed up,-c the table to be backed up,-o which folder to output,-- authenticationDatabase the database where the user's credentials are saved

Mongodump-- host IP_ADDRESS:27017-u "root"-p "PASSWD"-- authenticationDatabase "admin"-d DBname_test-o DBname_test20190328

Mongorestore-host IP_ADDRESS:27017-u "root"-p "PASSWD"-authenticationDatabase "admin"-d DBname_test DBname_test20190328

1. Output mongoexport-h IP_ADDRESS-u root-p PASSWD-- port 27017-- authenticationDatabase admin-d DB_name-c "COLLECTION_name"-o / root/COLLECTION_name.json-- type jsonmongoimport-h IP_ADDRESS-u root-p "PASSWD"-- port 27017-- authenticationDatabase admin-d DB_name-c "COLLECTION_name"-- type json-- file mongo_2019-10-29.json2 in json format, and query the number of data items.

Db.getCollection ('table name') .find ({"createdAt": {"$gte": ISODate ("2019-10-15T00:00:00.000+08:00"), "$lte": ISODate ("2019-10-30T00:00:00.000+08:00")}) .count ()

3. Import the data into jsono format through query statements.

Mongoexport-h IPADDRESS-u saas-p "PASSWD"-- port 217017-- authenticationDatabase admin-d saas-c "table name"-Q'{createdAt: {$gte:new Date (1571068800000), $lte:new Date (1572364800000)}'- o mongo$ (date +% F). Json-- type json

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

Internet Technology

Wechat

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

12
Report