This system provides automated incremental backup of MongoDB's oplog and includes tools for restoration when needed. The system consists of several scripts that work together to maintain a reliable backup history.
The orchestrator script that:
- Coordinates the execution of backup and cleanup operations
- Implements lock mechanism to prevent concurrent runs
- Logs all operations to
/mongo-oplog-dump/logs/
- Ensures scripts run in the correct sequence
- Handles error checking and logging
Performs the incremental backup by:
- Tracking the last backup point using TIMESTEMP and ITERATION files
- Determining the range of oplog entries to backup
- Creating compressed backups in
/mongo-oplog-dump/data/
- Handling first-time backups by starting from the earliest available oplog entry
Manages backup retention by:
- Monitoring the backup directory for folders matching "oplog.rs_data_till*"
- Maintaining the most recent 200 backup folders
- Automatically removing older backups when count exceeds 200
- Sorting folders by modification time to ensure proper cleanup
mainScript.sh
initiates the backup processdoIncrementalMongoOplogDump.sh
performs the incremental backupdeleteFoldersCountMoreThen200.sh
cleans up old backups- All operations are logged for monitoring and troubleshooting
A restoration tool that:
- Allows point-in-time recovery using oplog entries
- Processes multiple backup folders in chronological order
- Provides interactive confirmation before restoration
- Requires specific timestamp for restoration point
For detailed restoration instructions and steps, please refer to Restoring Guide Lines.md
- MongoDB server with authentication enabled
- Sufficient disk space for backups
- Execute permissions for all scripts
- Root access to MongoDB
/mongo-oplog-dump/
├── data/ # Backup storage location
├── logs/ # Log files directory
└── scripts/ # Location of all operation scripts
Each script contains configuration variables at the top:
- MongoDB connection details
- Authentication credentials
- Backup directory paths
- Retention settings
- All operations are logged to
/mongo-oplog-dump/logs/
- Log files are rotated daily
- Each log entry includes timestamp and operation details
- Scripts contain MongoDB authentication credentials
- Ensure proper file permissions
- Keep backup directories secure
- Monitor log files for unauthorized access attempts
- Check log files for error messages
- Verify MongoDB connectivity
- Ensure sufficient disk space
- Check file permissions
- Verify lock file is removed after script completion
For restoration procedures and additional details, consult the Restoring Guide Lines.md document.