# Restore a MongoDB backup

Download and restore a MongoDB dump file to any MongoDB database.

SimpleBackups stores MongoDB backups as compressed archive files. You restore them using `mongorestore` on any server with access to your target database. The `--nsFrom` and `--nsTo` flags let you restore into a differently-named database without editing the archive.

**This will overwrite the target database:**
Restoring a backup replaces all data in the target namespace with the contents of the backup file. Confirm you are restoring to the correct database before proceeding.

## Download the backup file

1. Go to your backup page and open the **Logs** tab. Click the **(i)** icon next to the backup run you want to restore.

![The backup log entry with the info icon highlighted](https://simplebackups.com/docs/docs-assets/www-notion-so/843e2fefe118f81420be.png)

2. In the modal that appears, click **Click to generate a signed download link** and copy the resulting URL.

3. On your server, download the backup using the signed URL:

```bash
wget "PASTE_SIGNED_DOWNLOAD_LINK_HERE" -O mongodb-backup.bin.gz
```

## Restore the database

Run `mongorestore` to restore the archive. Use `--nsFrom` and `--nsTo` to map the original database name to your target:

```bash
mongorestore --gzip --archive=mongodb-backup.bin.gz \
  --nsFrom "sampleDatabase.*" \
  --nsTo "newDbName.*"
```

Replace `sampleDatabase` with the name of the database as it appears in the backup, and `newDbName` with the name you want to restore into. You do not need to extract the archive before running this command.
