Export Data

Products

JCS for MongoDB

2022-02-21 08:24:33

Export Data

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.

Operation Steps

  1. Log in MongoDB Console.

  2. On the "Instance List" page, select the target instance and click Instance Name to go to the "Instance Details" page.

  3. Click Backup and Restore on the Instance Details page to view the backup data.

    View Backup

  4. Select the backup you want to download, and click Download in the action item to open the download pop-up window.

    View Backup

  5. Download the backup file locally.

    Description

    • The validity period of intranet address and Internet address is 24 hours.
    • English quotation marks shall be added to URL when download using wget
      1. If the virtual machine is in the same region with the cloud database, you are recommended to use the Intranet address for downloading;
  6. 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.

      1. Unzip the backup file to the specified path
      
        tar -C /xxx/data (mongod data storage path) -xf /yyy/mongo-xxxx.tar (backup file download path)
        
      1. Single Node Mode Start mongod Execute the following command to create a new configuration file mongod.conf in the /root/mongo folder:
      
        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
        
      1. Log in to mongo through mongo shell, delete local database
      
        mongo [--options]
        use local
        db.dropDatabase()
        
      1. Start the current node by the method of replica set Modify configuration file on all nodes:
      
        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 &
        
      1. Log in to mongo through mongo shell, use rs.initiate() on one and only one member of replica set
      
        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)
      
      1. Add a new member to the replica set (please make sure that the data in the newly added member -- dbpath directory is null)
      
        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/)
      

Related References

Feedback

开始与售前顾问沟通

可直接拨打电话 400-098-8505转1

我们的产品专家为您找到最合适的产品/解决⽅案

在线咨询 5*8⼩时

1v1线上咨询获取售前专业咨询

点击咨询
企微服务助手

专业产品顾问,随时随地沟通