Skip to content

Restore MongoDB Backup

In this guide, we'll demonstrate how to restore a MongoDB database backup using the mongorestore utility program. Mongorestore allows you to recover your data from a previously created backup.

Steps to Restore MongoDB Backup

Step 1: Upload the Backup File

Before you can restore a MongoDB backup, you need to upload the backup file generated from the source MongoDB to the Docker volume on MedStack Control.

Step 2: Navigate to the MongoDB Service Container

Once the backup file is uploaded, you can navigate to the MongoDB service container and execute the restoration command from the web shell.

  • Go to the Cluster Overview Page
  • In the "Services" Tab, Identify the MongoDB Service and Click "View"
  • Identify a Running Container and Click the "Shell" Button to SSH into the Container
  • Execute the Following Command from the Web Shell:
    cd /data/db; ls -l
    
  • Locate the Backup File
  • Restore from the Backup File Using the Following Command:
    mongorestore --uri="mongodb://user:password@host:port/?authSource=admin" \
                          --drop --noIndexRestore --gzip -v {backup directory location}
    
    Note: You will need to extract the compressed file that was uploaded to the volume in Step 1 before running the restore command.