Skip to content

Conversation

@mrrobot47
Copy link
Member

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()

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()
Copilot AI review requested due to automatic review settings December 24, 2025 05:23
Copy link
Contributor

Copilot AI left a 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 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() to EE::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.
@mrrobot47 mrrobot47 merged commit decc314 into EasyEngine:develop Dec 24, 2025
1 of 5 checks passed
@mrrobot47 mrrobot47 deleted the fix/7z-error-codes branch December 24, 2025 06:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant