You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+65-43Lines changed: 65 additions & 43 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,25 +13,49 @@
13
13
1.**Windows 10 OS 64-bit**
14
14
15
15
2.**MongoDB**
16
-
Version is not strict but for references, **MongoDB Community Server v4.2.0, OS Windows x86 x64**was used for this project's local installation.
16
+
Version is not strict, but for reference, the project used **MongoDB Community Server v4.2.0, OS Windows x86 x64** for its INITIAL local installation in 2019. Its shell must be available globally from the command line.
The project used **MongoDB Community Server v7.0.3, OS Windows x86 x64**, available on [the link](https://www.mongodb.com/try/download/community) for its LATEST local installation in 2023. This MongoDB version requires a separate installation of the MongoDB Shell and the MongoDB Database Tools (mongodump, mongorestore, etc). Its shell and tools must be available globally from the command line.
27
28
28
-
3. Access to an [mlab](https://mlab.com/) database (or any other mongodb database sources).
**MongoDB Command Line Database Tools** (MongoDB Database Tools) [[link]](https://www.mongodb.com/try/download/database-tools)
45
+
46
+
MongoDB Database Tools v100.9.3
47
+
Platform: Windows x86_64
48
+
Package: msi
49
+
50
+
3. Access to an [Atlas](https://www.mongodb.com/atlas) database (or any other mongodb database sources).
51
+
52
+
host: localhost
53
+
port: 27017
32
54
user: tester
33
55
password: tester
34
-
56
+
mongo shell:
57
+
- mongo (for MongoDB v4.2.0 or lower versions)
58
+
- mongosh (for MongoDB v4.4.0 or higher versions)
35
59
36
60
37
61
## Content
@@ -40,52 +64,50 @@ Version is not strict but for references, **MongoDB Community Server v4.2.0, OS
40
64
Windows batch script to automate switching of MongoDB database credentials for a faster database export `(mongodump)`, import `(mongorestore)` and database drop process.
3. The **MONGODB CONNECTION CREDENTIALS SETUP** screen will appear on the script's first-time run. Select the following options to encode the following required fields:
52
-
- **[1]** - database host name
53
-
- **[2]** - database name
54
-
- **[3]** - database user
55
-
- **[4]** - database user's password
56
-
57
-
4. Press **[6] - Save** to save the previously encoded database credentials for future use and exit to the main screen.
58
-
59
-
5. Press **[7] Save and Export Database** to save the previously encoded database credentials and start database export `(mongodump)`.
60
-
61
-
6. If you already have exported binary databases directories saved in this project's root directory, press **[8] - Save and Import Database** to save the previously encoded database credentials, and to start the database import `(mongorestore)` of the binary database which you will get to select on the resulting **AVAILABLE DATABASES TO IMPORT** screen.
62
-
63
-
64
-
7. Press **[9] Export Database** to start the database export process using the credentials that have been previously encoded.
65
-
> **NOTE:** Any updates made to the database credentials will NOT be saved if this option is chosen.
66
-
67
-
8. Press **[10] Import Database** to select a binary database to import from the **AVAILABLE DATABASES TO IMPORT** screen. A list of exported binary database directories will be listed.
68
-
> **NOTE:** Any updates made to the database credentials will NOT be saved if this option is chosen.
69
-
- Enter the name of the database you want to import, or
70
-
- Press **"x"** to exit.
71
-
72
-
9. Wait for the database export `(mongodump)` or import `(mongorestore)` process to finish.
73
-
74
-
10. Quick links for database import, export, drop and database credentials updating are available in the **VIEWING THE [ACTIVE] MONGODB CONNECTION CREDENTIALS** screen, which will be accessible after saving the initial database credentials required from **# 3**.
75
-
-**[1] - Export Database**
76
-
-**[2] - Import Database**
77
-
-**[3] - Drop Database**
78
-
-**[4] - Update Connection Credentials**
79
-
-**[5] - Reset**
80
-
-**[x] - Exit**
81
-
74
+
3. The **MONGODB CONNECTION CREDENTIALS SETUP** screen will appear on the script's first run. Select the following options to encode the following required fields:
75
+
76
+
| NO. | Prompt | Description |
77
+
|---|---|---|
78
+
| 1 | Enter database host | MongoDB host name |
79
+
| 2 | Enter database name | MongoDB database name |
80
+
| 3 | Database port | MongoDB port number name. Uses 27017 by default. |
81
+
| 4 | Enter user name | MongoDB user name |
82
+
| 5 | Enter password | MongoDB user password |
83
+
| 6 | Enter mongo shell | The available and active MongoDB shell. Choose:<br> - `mongo` (for MongoDB v4.2.0 or lower versions) <br>- `mongosh` (for MongoDB v4.4.0 or higher versions)|
84
+
| 7 | Save | Saves the encoded database credentials for future use to a `.env` and exit to the main screen. |
85
+
| 8 | Save and Export Database | Saves the mongodb settings to a `.env` file and starts the Export Database process. |
86
+
| 9 | Save and Import Database | Saves the mongodb settings to a `.env` file and starts to the Import Database process. |
87
+
| 10 | Export Database | Exports (`mongodump`) Exports the database defined in the MongoDB Connection Credentials Setup to a database in binary JSON format.<br> - **NOTE:** Choosing this option will NOT save recent updates made to the database credentials. |
88
+
| 11 | Import Database | Imports (`mongorestore`) a binary database to the database defined in the MongoDB Connection Credentials settings.<br>It expects to find binary database contents in subdirectories relative to the script, similar to the output of the **[10] Export Database option**.<br>**NOTE:** Choosing this option will NOT save recent updates made to the database credentials. |
89
+
| x | Exit | Exit the script. |
90
+
91
+
4. The **VIEWING THE [ACTIVE] MONGODB CONNECTION CREDENTIALS** screen provides quick links for database import, export, drop, and database credentials updating, which will be accessible after saving the initial database credentials required from the **MONGODB CONNECTION CREDENTIALS SETUP**.
92
+
93
+
| NO. | Prompt | Description |
94
+
|---|---|---|
95
+
| 1 | Export Database | Exports (`mongodump`) the database defined in the MongoDB Connection Credentials Setup to a binary JSON format database. |
96
+
| 2 | Import Database | Imports (`mongorestore`) the database defined in the MongoDB Connection Credentials settings to a local binary JSON format database relative to the script's location |
97
+
| 3 | Drop Database | It deletes a database defined in the MongoDB connection credentials. Currently available only for localhost MongoDB. |
98
+
| 4 | Update Connection Credentials | Displays the **MONGODB CONNECTION CREDENTIALS SETUP** screen for editing the stored database connection details. |
1. MonogoDB databases that are to be accessed using this tool are expected to have been properly set-up with users and passwords.
87
-
88
-
2. If the **export database** process takes too long to finish, close this tool and re-check if the database credentials haven been encoded properly.
105
+
1. This script expects to access properly configured MonogoDB databases with existing users and passwords.
106
+
2. The script expects a properly set up and configured MongoDB installation.
107
+
- The `"mongod,"``"mongodump,"``"mongorestore,"``"mongosh"` (for MongoDB v4.4 or later versions), and `"mongo"` (for MongoDB v4.2 or earlier versions) MongoDB shell commands should be globally accessible from the command prompt.
108
+
2. If the **Export Database** process takes too long to finish:
109
+
- Terminate and re-run the script.
110
+
- Re-check if the correct database credentials are available in the **MONGODB CONNECTION CREDENTIALS SETUP** screen.
0 commit comments