Refactor: Separate DB backup into standalone tool - #192
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR successfully refactors database backup and restore functionality from being embedded within migration tools to standalone, reusable backup tools. The changes improve code organization, maintainability, and testability through composition over inheritance.
Key changes:
- Created standalone
PostgreSQLBackupToolandMongoDBBackupToolclasses with comprehensive backup, restore, validation, and management capabilities - Refactored migration tools to use composition with backup tools via
backup_toolattribute instead of embedded backup methods - Added CLI interfaces for both PostgreSQL and MongoDB backup tools with commands for create, restore, validate, list, and delete operations
- Removed 572 lines of duplicated backup validation code
Reviewed changes
Copilot reviewed 41 out of 42 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
src/madsci_common/madsci/common/backup_tools/ |
New standalone backup tool implementations with PostgreSQL and MongoDB support, including validators, managers, and CLI interfaces |
src/madsci_common/madsci/common/types/backup_types.py |
New backup configuration types for PostgreSQL and MongoDB |
src/madsci_resource_manager/madsci/resource_manager/migration_tool.py |
Refactored to use PostgreSQLBackupTool composition, removing 443 lines of embedded backup code |
src/madsci_common/madsci/common/mongodb_migration_tool.py |
Refactored to use MongoDBBackupTool composition, removing 352 lines of embedded backup code |
src/**/tests/ |
Updated test files to mock backup_tool attribute instead of direct backup methods |
src/madsci_common/tests/test_backup_tools/ |
Comprehensive new test suites for backup tools, validators, managers, and CLIs |
src/madsci_common/pyproject.toml |
Added CLI entry points and new dependencies (psycopg2-binary, click) |
src/madsci_data_manager/madsci/data_manager/schema.json |
Schema version bump and index removal (unrelated to backup refactoring) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Dozgulbas
reviewed
Dec 3, 2025
Dozgulbas
reviewed
Dec 3, 2025
Dozgulbas
left a comment
Contributor
There was a problem hiding this comment.
It looks very nice! Curios about the usage of some of the parts. Also do you foresee that the backup tooling can be used other than DB migration backups?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Info
madsci-backupCLI command tomadsci.commonDeveloper Checklists
I have: