Last active
August 1, 2020 13:17
-
-
Save Anil8753/b247347205b74e97f36b435e11a73c40 to your computer and use it in GitHub Desktop.
MongoDB Backup and Restore
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Reference: | |
| https://www.w3resource.com/mongodb/mongodb-backup-restore.php | |
| "============ BACKUP ===========" | |
| Default | |
| Dumps all the databases into current directory | |
| D:\mongodb\bin>mongodump | |
| Backup a Database with mongodump specify the --host and --port | |
| D:\mongodb\bin>mongodump --host 19.110.108.46 --port 27017 | |
| Backup a Database with mongodump specify different output directory | |
| D:\mongodb\bin>mongodump --out /backup_data/backup/ | |
| Backup of a specific collection and a specific database using mongodump | |
| D:\mongodb\bin>mongodump --collection userdetails --db myinfo | |
| Create Backups from Non-Local mongod Instances | |
| mongodump --host [host name] --port 3017 --username [user] --password [pass] --out [backup folder path of local machine] | |
| for example, the path of the folder like : /backup_data/backup/ | |
| "============ RESTORE ===========" | |
| Default | |
| D:\mongodb\bin>mongorestore | |
| Restore Backups to Non-Local mongod Instances | |
| mongorestore --host [host name]:[port] [backup folder path of local machine] | |
| mongorestore --host [host name] --port 3017 --username [user] --password [password] [backup folder path of local machine] | |
| for example, the path of the folder like : /backup_data/backup/ | |
| Dump from atlas URI | |
| Anil-iMac:bin anil$ ./mongodump --uri "mongodb+srv://USER_NAME:[email protected]/YOUR_DB_NAME?authSource=admin&replicaSet=atlas-m2x7xg-shard-0&readPreference=primary&appname=MongoDB%20Compass%20Community&ssl=true" --out /Users/anil/Development/Personal/mongodb-database-tools-macos-x86_64-100.1.1/bin/bkup |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment