Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laravel Backup Restore Laravel Package

wnx/laravel-backup-restore

Restore database backups created by spatie/laravel-backup. Adds an interactive php artisan backup:restore command to pick a backup and optionally decrypt it, then run configurable post-restore health checks to validate the restored DB.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Database-Centric Focus: The package is tightly coupled with spatie/laravel-backup, making it ideal for Laravel applications already using that package for database backups. It extends the backup workflow by enabling restore operations without reinventing the wheel.
  • Modular Design: The health-check system allows for custom validation logic, making it adaptable to domain-specific requirements (e.g., verifying critical data post-restore).
  • Laravel Integration: Leverages Laravel’s Artisan CLI, configuration system (config/backup.php), and dependency injection, ensuring seamless adoption in existing Laravel stacks.
  • Limitation: No file restore support (only database), which may require complementary solutions (e.g., manual file handling or third-party tools) for full system recovery.

Integration Feasibility

  • Prerequisites:
    • Existing spatie/laravel-backup setup (backward compatibility with v10+).
    • Laravel 12+ and PHP 8.4+ (hard dependency).
    • Database drivers (MySQL/PostgreSQL/SQLite) must be configured in config/backup.php.
  • Compatibility:
    • High with Laravel’s ecosystem (uses Artisan, config files, and service providers).
    • Low risk for PHP/Laravel version upgrades (active maintenance, supports Laravel 13).
  • Dependencies:
    • Relies on spatie/laravel-backup (v10+) for backup files, encryption keys, and storage configurations.
    • No external APIs or services (self-contained).

Technical Risk

  • Critical Risks:
    • GTID Conflicts (MySQL): Restoring backups from managed services (e.g., DigitalOcean) may fail due to GTID settings. Requires preemptive configuration (--set-gtid-purged=OFF).
    • Data Corruption: Health checks mitigate this but cannot guarantee 100% data integrity (e.g., custom logic may miss edge cases).
  • Moderate Risks:
    • Multi-Tenant Environments: Unsupported (requires manual isolation).
    • Encryption Key Management: Passwords must be securely stored (e.g., Laravel’s .env or secrets manager).
  • Mitigation:
    • Pre-Restore Validation: Use the GitHub Actions workflow to test backups periodically.
    • Backup Testing: Implement custom health checks for critical data (e.g., MyCustomHealthCheck example).

Key Questions

  1. Backup Strategy:
    • Are backups encrypted? If so, how are passwords managed (e.g., secrets manager, .env)?
    • What’s the retention policy for backups? Does the package align with it (e.g., --keep flag)?
  2. Database Compatibility:
    • Are all databases (MySQL/PostgreSQL/SQLite) supported in production? Test PostgreSQL binary dumps if used.
    • Are there GTID-related constraints (e.g., managed MySQL services)?
  3. Operational Workflow:
    • How will restores be triggered (manual, CI/CD, cron)? Does --no-interaction suffice for automation?
    • Who owns post-restore validation (e.g., custom health checks)?
  4. Disaster Recovery:
    • Is there a fallback plan if restores fail (e.g., manual SQL imports)?
    • How are failed restores logged/alerted (e.g., GitHub Actions notifications)?

Integration Approach

Stack Fit

  • Core Stack: Laravel 12+/PHP 8.4+ with spatie/laravel-backup (v10+).
  • Storage: Supports any disk configured in config/backup.php (local, S3, FTP, etc.).
  • Databases: MySQL, PostgreSQL, SQLite (with caveats for GTID/PostgreSQL binary dumps).
  • Extensions:
    • Health Checks: Custom classes for domain-specific validation.
    • GitHub Actions: Automated backup integrity testing.

Migration Path

  1. Prerequisite Check:
    • Verify spatie/laravel-backup is installed and configured (config/backup.php).
    • Confirm Laravel/PHP versions meet requirements.
  2. Installation:
    composer require wnx/laravel-backup-restore
    php artisan vendor:publish --tag="backup-restore-config"
    
  3. Configuration:
    • Update config/laravel-backup-restore.php (health checks, defaults).
    • Ensure config/backup.php aligns with restore needs (e.g., GTID settings).
  4. Testing:
    • Run php artisan backup:restore --help to validate CLI options.
    • Test with a staging backup (not production) using --keep to inspect files.
  5. Automation:
    • Integrate with CI/CD (e.g., GitHub Actions workflow) for scheduled validation.
    • Document manual restore procedures (e.g., for emergencies).

Compatibility

  • Backward Compatibility:
    • Works with spatie/laravel-backup v10+ (tested up to v10.x).
    • Laravel 12/13 support; drops PHP 8.2/8.3 and Laravel 10/11.
  • Forward Compatibility:
    • Active maintenance (releases every 1–2 months). Monitor for Laravel 14 support.
  • Edge Cases:
    • PostgreSQL Binary Dumps: Requires pg_dump/pg_restore compatibility.
    • Multi-Region Storage: Ensure disk configurations (e.g., S3 paths) are accessible.

Sequencing

  1. Pre-Restore:
    • Backup Validation: Run health checks or GitHub Actions workflows to confirm backups are restorable.
    • Environment Prep: Ensure target database is empty (use --reset) or compatible.
  2. Restore Execution:
    • Dry Run: Use --keep to inspect downloaded/decrypted files before restoring.
    • Automated Runs: Use --no-interaction for CI/CD or cronjobs.
  3. Post-Restore:
    • Validation: Custom health checks or manual verification (e.g., query critical data).
    • Cleanup: Remove temporary files (unless --keep was used).

Operational Impact

Maintenance

  • Package Updates:
    • Monitor for wnx/laravel-backup-restore and spatie/laravel-backup updates.
    • Test upgrades in staging before production (e.g., Laravel 13 support in v1.9.2).
  • Configuration Drift:
    • Track changes to config/backup.php and config/laravel-backup-restore.php.
    • Document custom health checks and their logic.
  • Dependency Management:
    • Ensure PHP extensions (e.g., pdo_mysql, pdo_pgsql) are installed on all environments.

Support

  • Troubleshooting:
    • Common Issues:
      • GTID errors: Add --set-gtid-purged=OFF to config/backup.php.
      • Missing backups: Verify disk paths and permissions in config/backup.php.
      • Health check failures: Debug custom checks with Result::failed() messages.
    • Logging: Enable Laravel’s debug mode (APP_DEBUG=true) for detailed error output.
  • Escalation Path:
    • For critical failures, fall back to manual SQL imports or prior backups.
    • Open issues on the GitHub repo for edge cases.

Scaling

  • Performance:
    • Restore time scales with database size. For large databases:
      • Use --reset to avoid conflicts with existing data.
      • Schedule restores during low-traffic periods.
    • Parallelism: Not supported (restores are sequential).
  • Resource Usage:
    • Decryption and database imports may require significant CPU/RAM (test with production-sized backups).
    • Temporary files (e.g., decrypted backups) may consume disk space (use --keep cautiously).
  • Multi-Environment:
    • Ensure APP_NAME and config/backup.php are consistent across environments (backups are named by APP_NAME).

Failure Modes

Failure Scenario Impact Mitigation
Corrupted Backup File Restore fails Use GitHub Actions workflow to validate backups regularly.
GTID Conflict (MySQL) Restore blocks Configure --set-gtid-purged=OFF in config/backup.php.
Incorrect Encryption Password Decryption fails Store passwords in secrets manager; use --password flag carefully.
Health Check Fails Restore marked as failed Review custom health checks; add logging to debug failures.
Disk Permissions Issues Backup files inaccessible Ensure storage disks (e.g., S3) have proper IAM roles/permissions.
Database Connection Errors Restore
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
codraw/framework-extra-bundle
codraw/messenger
codraw/security
codraw/mailer
codraw/contracts
codraw/profiling
codraw/dependency-injection
codraw/tester
codraw/core
nexmo/api-specification
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony