Help Center> Document Database Service> User Guide> Backup and Restore> Restoring Single Node Instance to a Local Self-Built Database

Restoring Single Node Instance to a Local Self-Built Database

Scenarios

This section uses the Linux operating system as an example to describe how to restore the downloaded backup files of a single node instance to your self-built databases. To download backup files, see Downloading Backup Files.

This method applies only to single node instances.

Prerequisites

The client tool of version 3.4 has been installed on your local self-built MongoDB database.

Procedure

  1. Download the backup file of the single node.
  2. Log in to the device that can access the self-built database.
  3. Upload the single-node backup file to the device that can access the self-built database.

    Select an uploading method based on the OS you are using. In Linux, for example, run the following command:

    scp -r <IDENTITY_DIR> <REMOTE_USER>@<REMOTE_ADDRESS>:<REMOTE_DIR>

    • IDENTITY_DIR indicates the directory that stores the backup file.
    • REMOTE_USER indicates the username for logging in to the device that can access the self-built database.
    • REMOTE_ADDRESS indicates the IP address of the host that can access the self-built database.
    • REMOTE_DIR indicates the destination directory to which the backup file is imported.

    In Windows, upload the backup file using file transfer tools.

  4. Import the backup files in the self-built database.

    ./mongorestore --host <DB_HOST> --port <DB_PORT> -u <DB_USER> --authenticationDatabase <AUTH_DB> --drop --gzip --archive=<Backup directory> -vvvv --stopOnError

    • DB_HOST indicates the self-built database address.
    • DB_PORT indicates the self-built database port.
    • DB_USER indicates the self-built database username.
    • AUTH_DB indicates the database that authenticates DB_USER. Generally, this value is admin.
    • Backup directory indicates the backup file name.

    Enter the self-built database account password when prompted:

    Enter password:

    Example:

    ./mongorestore --host 192.168.6.187 --port 8635 -u rwuser --authenticationDatabase admin --drop --gzip --archive=xxx_tar.gz -vvvv --stopOnError