Mongodb GUI tool usage, data backup and recovery

Mongodb的GUI 工具使用、数据备份与恢复

Getting Started with MongoDb Compass

Official download address (free product, but no Chinese page) https://www.mongodb.com/try/download/compass

QQ%E5%9B%BE%E7%89%8720220918102412.png

Then there are not too many functions, but it is still refreshing.

QQ%E5%9B%BE%E7%89%8720220918102626.png

Then you can modify the data more intuitively

QQ%E5%9B%BE%E7%89%8720220918103007.png

QQ%E5%9B%BE%E7%89%8720220918103021.png

Mongodb data backup and recovery

For more information, please refer to the official website document

data backup

The reference command to initiate a backup is as follows

 mongodump -h localhost:27017 -d grasscutter -o /root/genshin/sql

Where -h is the connection IP:port to mongodb, -d is followed by the database name, -o is followed by a folder directory, preferably a blank folder

QQ%E5%9B%BE%E7%89%8720220918103501.png

Then it can be seen that the backup file is not a single file

QQ%E5%9B%BE%E7%89%8720220918103516.png

Data Recovery

If you want to modify the database name, it is better to use this method instead of directly modifying it.

The reference command is as follows

 mongorestore -h localhost:27017 -d gc /root/genshin/sql/grasscutter

Where -h is the connection IP:port to mongodb, -d is followed by the database name (other names can be customized, and does not need to be consistent with the original library), and a folder directory at the end (you can also use –dir to specify the backup directory) , just like the backup above

In addition, you can also add –drop (when restoring, delete the current data first, and then restore the backed up data) or you can manually clear it yourself

combat effect

The new library is found to be slightly smaller, which may be an index problem

QQ%E5%9B%BE%E7%89%8720220918103716.png

QQ%E5%9B%BE%E7%89%8720220918103819.png

QQ%E5%9B%BE%E7%89%8720220918103829.png

Data export and import via Studio 3T

Note that compass does not support batch exporting the entire library.

QQ%E5%9B%BE%E7%89%8720220918104802.png

With json, it can be used all the way by default, and other formats should also work

QQ%E5%9B%BE%E7%89%8720220918104813.png

QQ%E5%9B%BE%E7%89%8720220918104826.png

QQ%E5%9B%BE%E7%89%8720220918104835.png

QQ%E5%9B%BE%E7%89%8720220918104850.png

The resulting effect is shown in the figure

QQ%E5%9B%BE%E7%89%8720220918104919.png

Then import back to another library

QQ%E5%9B%BE%E7%89%8720220918104954.png

QQ%E5%9B%BE%E7%89%8720220918105016.png

QQ%E5%9B%BE%E7%89%8720220918105025.png

QQ%E5%9B%BE%E7%89%8720220918105103.png

Then I found that the previous blank table was not restored, but skipped directly.

QQ%E5%9B%BE%E7%89%8720220918105130.png

This article is reprinted from https://www.blueskyxn.com/202209/6590.html
This site is for inclusion only, and the copyright belongs to the original author.