This script allows you to migrate data from a live MongoDB database to a local MongoDB database.
- Python 3.x installed
- Pip package manager installed
-
Clone this repository:
git clone https://github.com/ennanuel/mongo-migrate.git
-
Navigate to the project directory:
cd your-repo
-
Install the required packages:
pip install -r requirements.txt
Create a .env
file in the project directory with the following content:
LIVE_MONGO_URI=your_live_mongo_uri
LOCAL_MONGO_URI=your_local_mongo_uri
Replace your_live_mongo_uri
and your_local_mongo_uri
with your actual MongoDB connection URIs.
Run the migration script using the following command:
python mongo_migration.py
Replace placeholders with your actual MongoDB connection URIs and database name.
- The script will clear existing data in the local database for each collection before migrating data.
- Make sure to have backups of your data before running the migration.