edit-icon download-icon

Physical backup and recovery

Last Updated: Dec 07, 2017

Download and decompression

Download the physical backup file and decompress the file to the data directory where MongoDB is located (the data directory must be empty). The following operation assumes that /path/to/mongo is the location directory for MongoDB to be started using the physical backup:

  1. cd /path/to/mongo/data/
  2. rm -rf *
  3. tar xzvf hins_xxx.tar.gz

Version and configuration requirements for MongoDB startup

  • MongoDB version: 3.2 or later.

  • ApsaraDB for MongoDB uses the WiredTiger storage engine by default and enables the directoryPerDB feature. Therefore, select related options in configuration.

  • The physical backup of ApsaraDB for MongoDB contains the replica set configuration of the original instance. Therefore, MongoDB must be started in single-node mode (the configuration file cannot contain configurations related to replication). Otherwise, access may fail. To start MongoDB in replica set mode, follow these steps after MongoDB is started in single-node mode:

    1. Remove the configurations of the original replica set.

      1. use local
      2. db.system.replset.remove({})
    2. Modify the configuration file to add configurations related to replication.

    3. Restart the mongod process.

    4. Reinitialize the replica set.

  • The physical backup of ApsaraDB for MongoDB contains the user name and password of the original instance. If authentication is enabled in the configuration file, use the user name and password of the original instance for access.

  • The following is the configuration template that uses the physical backup to start ApsaraDB for MongoDB (authentication is enabled for the single node):

    1. systemLog:
    2. destination: file
    3. path: /path/to/mongo/mongod.log
    4. logAppend: true
    5. security:
    6. authorization: enabled
    7. storage:
    8. dbPath: /path/to/mongo/data
    9. directoryPerDB: true
    10. net:
    11. http:
    12. enabled: false
    13. port: 27017
    14. unixDomainSocket:
    15. enabled: false
    16. processManagement:
    17. fork: true
    18. pidFilePath: /path/to/mongo/mongod.pid
Thank you! We've received your feedback.