This repository provides tools and scripts for setting up and managing MongoDB databases with backup and restore capabilities.
- Git
- Docker and Docker Compose
- Basic understanding of MongoDB
- Access to edit system files (for /etc/hosts modification)
-
Clone the Repository:
git clone [email protected]:vedmalex/db_setup.git cd db_setup
-
Create Backup Directory:
mkdir dump
The
dump
directory is used to store database backups. Each database can have special control files:.skip_dump
- Skip this database during backup operations.skip_restore
- Skip this database during restore operations.dumped
- Indicates successful backup completion.restored
- Indicates successful restore completion
-
Configure Environment Variables:
cp env.sample .env
Edit
.env
file to set your credentials:MONGO_ROOT_USERNAME=<your_username> MONGO_ROOT_PASSWORD=<your_secure_password>
-
Update Hosts File: Add these entries to your
/etc/hosts
file:127.0.0.1 mongo1 127.0.0.1 mongo2
-
User Management:
- Root user credentials are set in the
.env
file - Additional users can be added in
scripts/users.json
- Use
scripts/users.sample.json
as a template for user configuration
- Root user credentials are set in the
-
Start the Deployment:
./init.sh
-
Connect to MongoDB: Use this connection string format:
mongodb://<username>:<password>@mongo1:27017/<database>?authSource=admin&replicaSet=rs0
Contributions are welcome! Please feel free to submit a Pull Request.
Let me know if you'd like me to add any additional sections or details to the README, such as:
- Detailed backup/restore procedures
- Troubleshooting guide
- System requirements
- Configuration options
- Usage examples