Arcula - MongoDB Database Synchronization Tool
Arcula is a CLI application for synchronizing MongoDB databases between different environments. Named after the Roman god of transitions and passages, Arcula allows you to easily export databases from one MongoDB instance and import them to another.
Features
- Export databases from one MongoDB instance
- Import databases to another MongoDB instance
- Dynamic environment configuration (not limited to predefined environments)
- Create and restore backups
- Interactive mode with prompts for missing options
- Progress indicators for long-running operations
- Colored terminal output
- Automatic detection of MongoDB tools
Installation
Prerequisites
- MongoDB Tools (
mongodumpandmongorestoreexecutables) - Rust and Cargo (install from https://rustup.rs)
Build from source
# Clone the repository
# Build the project
# The binary will be available at target/release/arcula
Running with cargo
# Run directly with cargo
Configuration
Create a .env file in the root directory of the project with the following variables:
# MongoDB Connection URIs - You can add any environment you need
MONGO_LOCAL_URI=mongodb://localhost:27017
MONGO_DEV_URI=mongodb://user:password@dev.example.com:27017
MONGO_STG_URI=mongodb://user:password@stg.example.com:27017
MONGO_PROD_URI=mongodb://user:password@prod.example.com:27017
MONGO_GIO_URI=mongodb://user:password@gio.example.com:27017
# Path to MongoDB binaries (optional, auto-detected if not specified)
MONGODB_BIN_PATH=/usr/local/bin
# Backup directory
BACKUP_DIR=./backups
# Logging level: trace, debug, info, warn, error
RUST_LOG=info
You can copy the sample.env file and modify it for your needs. The application will dynamically detect all MongoDB environments from environment variables following the pattern MONGO_<ENV>_URI.
Usage
Display information about available environments
This command will show all configured MongoDB environments and their databases.
Synchronize databases between environments
Interactive mode (will prompt for missing options):
With command-line options:
Options:
--from: Source environment (any configured environment)--to: Target environment (any configured environment)--db: Database to synchronize--target-db: Target database name (defaults to source database name)--backup: Whether to create a backup before import (true/false, defaults to true)--drop: Whether to drop collections during import (true/false, defaults to true)--clear: Whether to clear collections during import (true/false, defaults to false, ignored if drop is enabled)--interactive: Enable interactive prompts
Examples
# Synchronize 'users' database from DEV to LOCAL environment with interactive prompts
# Synchronize 'products' database from PROD to STG environment without prompts
# Synchronize 'analytics' database from GIO to DEV environment with custom target db
Contributing
Contributions are welcome! Feel free to submit a pull request with your changes.
License
MIT