The cloud database MongoDB provides automatic backup and manual backup functions. To export data, you can download the backup file and export it to the local database.
Please pay attention to whether the backup mode of the current backup is physical backup or logical backup when it is exported. Their recovery methods are different.
Log in MongoDB Console.
On the "Instance List" page, select the target instance and click Instance Name to go to the "Instance Details" page.
Click Backup and Restore on the Instance Details page to view the backup data.
Select the backup you want to download, and click Download in the action item to open the download pop-up window.
Download the backup file locally.
Description
Import the backup file to the local database.
Please execute the following command when the backup is a logical.
mongorestore --host xxx --port=27017 --authenticationDatabase admin --archive=xxx(file path) --gzip -u root -p xxx
Please follow the steps below when the backup is physical.
tar -C /xxx/data (mongod data storage path) -xf /yyy/mongo-xxxx.tar (backup file download path)
touch /root/mongo/mongod.conf
Enter vi /root/mongo/mongod.conf in the command line to open the mongod.conf file, edit it, save and exit when done: (WiredTiger storage engine)
systemLog:
destination: file
path: /home/Logs/mongod.log
logAppend: true
security:
authorization: enabled
storage:
dbPath: /home/data
directoryPerDB: true
net:
port: 27017
unixDomainSocket:
enabled: false
processManagement:
fork: true
pidFilePath: /home/var/mongod.pid
Specify the newly created configuration file mongod.conf to start MongoDB:
mongod -f /root/mongo/mongod.conf
mongo [--options]
use local
db.dropDatabase()
bind_ip = ::,0.0.0.0
port = 27017
ipv6 = true
fork = false
pidfilepath = /home/var/mongod.pid
logappend = true
dbpath = /home/data
logpath = /home/Logs/mongod.log
maxConns = 500
replSet = rs0
keyFile = /home/etc/mongodb.key
timeStampFormat = iso8601-local
unixSocketPrefix = /home/var
auth = true
wiredTigerCacheSizeGB = 1
directoryperdb = true
setParameter = replWriterThreadCount=32
Start the service in the background separately on all nodes:
mongod --config /var/jmiss_mongo/config/mongod.conf &
mongo [--options]
rs.initiate( {
_id : <replName>,
members: [ { _id : 0, host : <host:port> } ]
})
[rs.initiate()Usage](https://docs.mongodb.com/master/reference/method/rs.initiate/#rs.initiate)
rs.add()
[rs.add()Usage](https://docs.mongodb.com/master/reference/method/rs.add/#rs.add) [MongoDB Replica Set Recovery Official Reference Document](https://docs.mongodb.com/master/tutorial/restore-replica-set-from-backup/)
我们的产品专家为您找到最合适的产品/解决⽅案
1v1线上咨询获取售前专业咨询
专业产品顾问,随时随地沟通