Restore a MongoDB database backup.
Full mongodump backup restore
Plain BackupEncrypted Backup
1. Decompress the backup using gunzip
:
$ cat /path/to/backup.tar.gz | gunzip > backup.tar.decompressed
Note
Ignore this step if the backup is not compressed.
2. Restore the backup using mongorestore
:
$ mongorestore --host=localhost --username=backup_user --archive=backup.tar.decompressed
1. To decrypt a backup, it’s recommended to disable command history (using set +o history
) when specifying the encryption key to decrypt and decompress the backup:
$ set +o history
$ bartender decrypt -k {the-encryption-key} -f /path/to/backup.tar.gz -x -o backup.tar.decrypted_decompressed
$ set -o history
Note
If the backup is not compressed, remove the -x
flag from the command above.
2. Restore the backup using mongorestore
:
$ mongorestore --host=localhost --username=backup_user --archive=backup.tar.decrypted_decompressed