improve backup database detection and container lookup#8
Merged
x0sina merged 3 commits intoPasarGuard:mainfrom Nov 1, 2025
x0sina:main
Merged
improve backup database detection and container lookup#8x0sina merged 3 commits intoPasarGuard:mainfrom x0sina:main
x0sina merged 3 commits intoPasarGuard:mainfrom
x0sina:main
Conversation
Contributor
|
Caution Review failedThe pull request is closed. WalkthroughEnhanced backup script with robust environment variable handling, multi-database-type detection (MariaDB, MySQL, PostgreSQL, TimescaleDB), granular container resolution, segregated local/remote database paths, consolidated error aggregation, and improved Telegram reporting with error summaries and log file links. Changes
Sequence DiagramsequenceDiagram
actor User
participant Script as pasarguard.sh
participant Env as .env
participant Docker as Docker/Container
participant DB as Database
participant Log as Log File
participant Telegram as Telegram
User->>Script: Execute backup_command
Script->>Env: Load SQLALCHEMY_DATABASE_URL
Note over Script: Strip surrounding quotes,<br/>log presence/content
Script->>Script: Parse DB host & type
Script->>Docker: Resolve container ID<br/>(running or via docker-compose)
Note over Script: Attempt container resolution<br/>per DB type
Script->>Script: Detect DB type<br/>(MariaDB/MySQL/PostgreSQL/TimescaleDB)
alt DB Type Detected
Script->>DB: Collect databases
alt Local Docker Container
Note over Script: Use MYSQL_ROOT_PASSWORD<br/>or fallback credentials
Script->>DB: Attempt root-user dump
alt Root dump succeeds
Script->>Log: Log backup success
else Root dump fails
Note over Script: Collect error
Script->>DB: Attempt app-user dump
alt App-user dump succeeds
Script->>Log: Log backup with fallback
else App-user dump fails
Script->>Log: Log error
end
end
else Remote Database
Note over Script: Mark as not yet supported,<br/>record error
Script->>Log: Log error
end
else No DB Type Detected
Note over Script: Warn and skip DB backup,<br/>continue with other steps
Script->>Log: Log warning
end
Script->>Script: Aggregate all errors
alt Errors exist
Script->>Telegram: Send error summary<br/>with log file link
Script->>Log: Write final error report
Script->>User: Return exit code 1
else No errors
Script->>Telegram: Send success notification
Script->>User: Return exit code 0
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes
Poem
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
Comment |
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.
Summary by CodeRabbit
Bug Fixes
New Features