fix(backup): handle 7z exit codes correctly to avoid false failures#473
Merged
mrrobot47 merged 3 commits intoEasyEngine:developfrom Dec 24, 2025
Merged
fix(backup): handle 7z exit codes correctly to avoid false failures#473mrrobot47 merged 3 commits intoEasyEngine:developfrom
mrrobot47 merged 3 commits intoEasyEngine:developfrom
Conversation
7z returns exit code 1 for non-fatal warnings (e.g., missing symlink targets like broken log file symlinks), but the archive is still created successfully. Previously, EE::exec() returned false for any non-zero exit code, causing false positive backup failures. Changes: - Switch from EE::exec() to EE::launch() to get actual exit codes - Only fail on exit code >= 2 (fatal errors), allow exit code 1 (warnings) - Add file existence checks as secondary validation - Custom docker-compose backup logs warning instead of failing (optional) 7z exit code reference: - 0: Success - 1: Warning (non-fatal, archive created) - 2: Fatal error - 7: Command line error - 8: Not enough memory Updated functions: - maybe_backup_custom_docker_compose() - backup_site_dir() - backup_wp_content_dir() - backup_nginx_conf() - backup_php_conf() - backup_db()
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes false backup failures caused by improper handling of 7z exit codes. The tool returns exit code 1 for non-fatal warnings (like missing symlink targets), but the previous implementation using EE::exec() treated any non-zero exit code as a failure. The changes properly distinguish between warnings (exit code 1) and fatal errors (exit code >= 2).
Key Changes:
- Switched from
EE::exec()toEE::launch()to access actual exit codes across all backup functions - Updated error handling to only fail on exit code >= 2, treating exit code 1 as non-fatal
- Added file existence checks in most functions as secondary validation
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
mrrobot47
added a commit
to mrrobot47/site-command
that referenced
this pull request
Dec 24, 2025
Add missing file existence check in backup_wp_content_dir() for consistency with other backup functions. This ensures the archive was actually created even when 7z returns exit code 0 or 1. Addresses GitHub Copilot review feedback on PR EasyEngine#473.
Add missing file existence checks in backup_wp_content_dir() and backup_db() for consistency with other backup functions. This ensures archive integrity is verified after all 7z operations.
3842c42 to
8022d20
Compare
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.
7z returns exit code 1 for non-fatal warnings (e.g., missing symlink targets like broken log file symlinks), but the archive is still created successfully. Previously, EE::exec() returned false for any non-zero exit code, causing false positive backup failures.
Changes:
7z exit code reference:
Updated functions: