A professional MongoDB backup solution that automatically dumps databases, compresses them, uploads to Cloudflare R2 storage, and sends status notifications via Telegram.
- 🗄️ Full MongoDB database backup
- 🗜️ Maximum compression to save storage space
- ☁️ Secure upload to Cloudflare R2 storage
- 📱 Real-time status updates via Telegram
- 📊 Progress tracking for large backups
- 🔄 Automatic cleanup of temporary files
The project is organized into multiple Python files for better maintainability:
main.py- Main script that orchestrates the backup processconfig.py- Configuration settings for R2 and Telegrambackup_manager.py- Handles database dumps, compression, and uploadstelegram_notifier.py- Manages Telegram notificationsprogress_tracker.py- Tracks and reports upload progressrequirements.txt- List of required Python packages
- Python 3.8+
- MongoDB installed and accessible
- Cloudflare R2 storage account
- Telegram bot token and channel
- Clone the repository:
git clone https://github.com/AppleEcosystem/MongodBackup.git- Install required packages
pip3 install -r requirementsEdit the config.py file to set your credentials:
# R2 Configuration
R2_BUCKET = 'backups' # Your R2 bucket name
R2_ENDPOINT = 'https://your-account-id.r2.cloudflarestorage.com'
R2_ACCESS_KEY_ID = 'your-access-key'
R2_SECRET_ACCESS_KEY = 'your-secret-key'
# Telegram Configuration
TELEGRAM_TOKEN = 'your-telegram-bot-token'
TELEGRAM_CHANNEL_ID = 'your-channel-id'
TELEGRAM_API_URL = f'https://api.telegram.org/bot{TELEGRAM_TOKEN}