{"id":22341753,"url":"https://github.com/weaponsforge/mongo-importex","last_synced_at":"2025-03-26T09:27:56.351Z","repository":{"id":126828455,"uuid":"221922799","full_name":"weaponsforge/mongo-importex","owner":"weaponsforge","description":"Utility for importing, exporting and dropping MongoDB databases","archived":false,"fork":false,"pushed_at":"2024-04-07T04:34:07.000Z","size":34,"stargazers_count":1,"open_issues_count":3,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-31T10:44:35.870Z","etag":null,"topics":["batch-script","batchfile","mongodb","mongodump","mongorestore","mongosh","tools"],"latest_commit_sha":null,"homepage":"","language":"Batchfile","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/weaponsforge.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2019-11-15T12:47:52.000Z","updated_at":"2024-10-23T13:09:18.000Z","dependencies_parsed_at":"2024-04-08T05:00:17.272Z","dependency_job_id":null,"html_url":"https://github.com/weaponsforge/mongo-importex","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weaponsforge%2Fmongo-importex","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weaponsforge%2Fmongo-importex/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weaponsforge%2Fmongo-importex/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weaponsforge%2Fmongo-importex/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/weaponsforge","download_url":"https://codeload.github.com/weaponsforge/mongo-importex/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245625192,"owners_count":20646105,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["batch-script","batchfile","mongodb","mongodump","mongorestore","mongosh","tools"],"created_at":"2024-12-04T08:08:09.158Z","updated_at":"2025-03-26T09:27:56.332Z","avatar_url":"https://github.com/weaponsforge.png","language":"Batchfile","readme":"# mongo-importex\n\n\u003e A one-click windows utility tool that:  \n\u003e\n\u003e - Exports `(mongodump)` a mongodb database in binary format.\n\u003e - Imports `(mongorestore)` the exported binary database into a new database.\n\u003e - Drops a specified localhost database.\n\n### Table of Contents\n\n- [Dependencies](#dependencies)\n- [Content](#content)\n- [Usage and Installation](#usage-and-installation)\n- [Troubleshooting](#troubleshooting)\n\n\n\n### Dependencies\n\n1. **Windows 10 OS 64-bit**\n\n2. **MongoDB**  \nVersion 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.\n\n\t\tMongoDB shell version v4.2.0\n\t\tgit version: a4b751dcf51dd249c5865812b390cfd1c0129c30\n\t\tallocator: tcmalloc\n\t\tmodules: none\n\t\tbuild environment:\n\t\t  distmod: 2012plus\n\t\t  distarch: x86_64\n\t\t  target_arch: x86_64\n\n\tThe 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.\n\n\t\tMongoDB (mongod) version v7.0.3\n\t\tgit version: b96efb7e0cf6134d5938de8a94c37cec3f22cff4\n\t\tallocator: tcmalloc\n\t\tmodules: none\n\t\tbuild environment:\n\t\t\tdistmod: windows\n\t\t\tdistarch: x86_64\n\t\t\ttarget_arch: x86_64\n\n\t**MongoDB Shell** [[link]](https://www.mongodb.com/try/download/shell)\n\n\t\tMongoDB Shell v2.0.2\n\t\tPlatform: Windows x64 (10+)\n\t\tPackage: msi\n\n\t**MongoDB Command Line Database Tools** (MongoDB Database Tools) [[link]](https://www.mongodb.com/try/download/database-tools)\n\n\t\tMongoDB Database Tools v100.9.3\n\t\tPlatform: Windows x86_64\n\t\tPackage: msi\n\n3. Access to an [Atlas](https://www.mongodb.com/atlas) database (or any other mongodb database sources).  \n\n\t\thost: localhost\n\t\tport: 27017\n\t\tuser: tester\n\t\tpassword: tester\n\t\tmongo shell: \n\t\t- mongo (for MongoDB v4.2.0 or lower versions)\n\t\t- mongosh (for MongoDB v4.4.0 or higher versions)\n\n\n## Content\n\n1. **main.bat**  \nWindows batch script to automate switching of MongoDB database credentials for a faster database export `(mongodump)`, import `(mongorestore)` and database drop process.\n\n\n## Usage and Installation\n\n1. Clone this repository.  \n`git clone https://github.com/weaponsforge/mongo-importex.git`\n\n2. Click to run **main.bat**.\n\n3. The **MONGODB CONNECTION CREDENTIALS SETUP** screen will appear on the script's first run. Select the following options to encode the following required fields:  \n\n\t| NO. | Prompt | Description |\n\t|---|---|---|\n\t| 1 | Enter database host | MongoDB host name |\n\t| 2 | Enter database name | MongoDB database name |\n\t| 3 | Database port | MongoDB port number name. Uses 27017 by default. |\n\t| 4 | Enter user name | MongoDB user name |\n\t| 5 | Enter password | MongoDB user password |\n\t| 6 | Enter mongo shell | The available and active MongoDB shell. Choose:\u003cbr\u003e - `mongo` (for MongoDB v4.2.0 or lower versions) \u003cbr\u003e- `mongosh` (for MongoDB v4.4.0 or higher versions)|\n\t| 7 | Save | Saves the encoded database credentials for future use to a `.env` file and exit to the main screen. |\n\t| 8 | Save and Export Database | Saves the mongodb settings to a `.env` file and starts the **Export Database** process. |\n\t| 9 | Save and Import Database | Saves the mongodb settings to a `.env` file and starts to the **Import Database** process. |\n\t| 10 | Export Database | Exports (`mongodump`) the database defined in the MongoDB Connection Credentials Setup to a database in binary JSON format.\u003cbr\u003e - **NOTE:** Choosing this option will NOT save recent updates made to the database credentials.\u003cbr\u003e- Type `\"Y\"` and press ENTER if you want to use the `\"mongo+srv://\"` SRV Connection String.\u003cbr\u003e- Type `\"n\"` and press ENTER if you want to use the `\"mongo://\"` Standard Connection String. |\n\t| 11 | Import Database | Imports (`mongorestore`) a binary database to the database defined in the MongoDB Connection Credentials settings.\u003cbr\u003eIt expects to find binary database contents in subdirectories relative to the script, similar to the output of the **[10] Export Database option**.\u003cbr\u003e- **NOTE:** Choosing this option will NOT save recent updates made to the database credentials.\u003cbr\u003e- Type `\"Y\"` and press ENTER if you want to use the `\"mongo+srv://\"` SRV Connection String.\u003cbr\u003e- Type `\"n\"` and press ENTER if you want to use the `\"mongo://\"` Standard Connection String. |\n\t| x | Exit | Exit the script. |\n\n4. 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**.\u003cbr\u003e\n\n\tThe **Export Database**, **Import Database**, and **List Databases** options will prompt selecting the `\"mongo+srv://\"` SRV Connection String. Type `\"Y\"` or `\"n\"` and press ENTER when prompted.\n\t- Type `\"Y\"` and press ENTER if you want to use the `\"mongo+srv://\"` SRV Connection String.\n\t- Type `\"n\"` and press ENTER if you want to use the `\"mongo://\"` Standard Connection String.\n\n\t| NO. | Prompt | Description |\n\t|---|---|---|\n\t| 1 | Export Database | Exports (`mongodump`) the database defined in the MongoDB Connection Credentials Setup to a binary JSON format database. |\n\t| 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 |\n\t| 3 | Drop Database | It deletes a database defined in the MongoDB connection credentials. Currently available only for localhost MongoDB. |\n\t| 4 | List Databases | Lists the available databases from the defined MongoDB connection credentials. |\n\t| 5 | List Local Databases | Lists the available localhost databases. |\n\t| 6 | Local DB User: Create | Creates a local user for a local database that may or may not yet exist. |\n\t| 7 | Local DB User: Delete | Deletes a local user from a local database that may or may not yet exist. |\n\t| 6 | Local DB User: List | Lists all local user/s of a local database that may or may not yet exist. |\n\t| 9 | Update Connection Credentials | Displays the **MONGODB CONNECTION CREDENTIALS SETUP** screen for editing the stored database connection details. |\n\t| 10 | Mongo Shell | Starts a MongoDB shell and connect to a MongoDB database. |\n\t| 11 | Reset | Resets the database conection details |\n\t| x | Exit | Exit the script. |\n\n5. If the local MongoDB does not yet have a local database user, you can try creating one by selecting option #6.\n\n## Troubleshooting\n\n1. This script expects to access properly configured MonogoDB databases with existing users and passwords.\n2. The script expects a properly set up and configured MongoDB installation.\n   - 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.\n2. If the **Export Database** process takes too long to finish:\n   - Terminate and re-run the script.\n   - Re-check if the correct database credentials are available in the **MONGODB CONNECTION CREDENTIALS SETUP** screen.\n\n\n20191116","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fweaponsforge%2Fmongo-importex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fweaponsforge%2Fmongo-importex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fweaponsforge%2Fmongo-importex/lists"}