-
Notifications
You must be signed in to change notification settings - Fork 28
Backup cleanup improvement #470
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Backup cleanup improvement #470
Conversation
…tion Implement intelligent backup cleanup that only deletes old backups when EasyDash API successfully registers the new backup. If API callback fails, rollback the newly uploaded backup to prevent orphaned backups in remote storage. Key changes: - Add conditional cleanup based on API callback success/failure - Implement rollback mechanism to delete unregistered backups - Extend retry logic to handle connection errors (DNS, timeouts, etc.) - Add proper return values to API callback methods - Remove dead code from error handling paths - Optimize backup path tracking to only when dash-auth is enabled Retry behavior: - Retries 5xx server errors (500-599) - Retries connection errors (connection refused, DNS failures, timeouts) - Retries HTTP 0 (no response received) - Does NOT retry 4xx client errors - Max 3 retries with 5-minute delays between attempts Error handling improvements: - Changed rollback deletion failure from error to warning for consistency - Clear error messages distinguish between retry attempts and final failures - Proper "after N retries" messaging for all retryable errors
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR implements intelligent backup cleanup that conditionally deletes old backups based on EasyDash API callback success. When the API callback fails, the newly uploaded backup is rolled back to prevent orphaned backups in remote storage that aren't tracked by EasyDash.
Key changes:
- Add conditional cleanup that only removes old backups after successful API registration
- Implement rollback mechanism to delete unregistered backups when API callback fails
- Extend retry logic to handle connection errors (DNS failures, timeouts, connection refused) in addition to 5xx errors
Comments suppressed due to low confidence (1)
src/helper/Site_Backup_Restore.php:1104
- While
$backupcomes from remote directory listing which should be safe, consider addingescapeshellarg()to the sprintf format for defense in depth, similar to line 1132 where the full path is escaped. This ensures consistency in shell command construction and protects against potential injection if the backup naming format ever changes.
$result = EE::launch( sprintf( 'rclone purge %s/%s', $this->get_rclone_config_path(), $backup ) );
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Implement intelligent backup cleanup that only deletes old backups when
EasyDash API successfully registers the new backup. If API callback
fails, rollback the newly uploaded backup to prevent orphaned backups
in remote storage.
Key changes:
Retry behavior:
Error handling improvements: