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

  • Complementary to Existing Stack: This package is designed to work exclusively with spatie/laravel-backup, making it a natural fit for Laravel applications already using that package for database backups. It extends the backup workflow by enabling restoration, closing a critical gap in the backup lifecycle.
  • Modular Design: The package follows Laravel’s conventions (Artisan commands, config publishing, service providers) and integrates seamlessly with existing Laravel applications. The health-check system is extensible, allowing custom validation logic post-restore.
  • Database-Centric: Focuses solely on database restoration (not files), aligning with use cases where database integrity is paramount (e.g., staging environments, disaster recovery).

Integration Feasibility

  • Low Friction: Requires minimal setup (composer install + config publish) and leverages existing config/backup.php for disk, encryption, and connection settings.
  • Dependency Alignment:
    • Laravel 12+ and PHP 8.4+ are mandatory, which may require upgrades for older stacks.
    • Hard Dependency on spatie/laravel-backup (v9+) means the package is useless without it. This is a blocker if the app doesn’t use Spatie’s backup.
  • Artisan Command Integration: The backup:restore command follows Laravel’s CLI patterns, making it familiar to developers.

Technical Risk

  • GTID/Replication Conflicts: MySQL GTID issues (e.g., DigitalOcean managed DBs) can block restores. Mitigation requires pre-backup configuration (--set-gtid-purged=OFF).
  • Multi-Tenant Limitations: Explicitly unsupported in multi-tenant setups (e.g., Laravel Nova, Filament). Risk: data leakage if misconfigured.
  • Encryption Handling: Relies on config/backup.php for decryption keys. Key management becomes critical (e.g., secrets in CI/CD, environment variables).
  • No File Restoration: If the app backs up both DB + files, this package won’t restore files, requiring parallel solutions (e.g., manual S3 downloads).

Key Questions

  1. Backup Strategy Compatibility:
    • Does the app use spatie/laravel-backup (v9+) for DB backups? If not, this package is incompatible.
    • Are backups encrypted? If yes, how are decryption keys managed (env vars, secrets manager)?
  2. Database Environment:
    • Are there GTID/replication constraints (e.g., DigitalOcean, AWS RDS) that could block restores?
    • Is the target DB schema identical to the backup’s? (Schema drift may cause failures.)
  3. Operational Workflow:
    • Will restores be manual (CLI) or automated (CI/CD)? The --no-interaction flag is critical for automation.
    • Are there custom health checks needed (e.g., verifying critical data post-restore)?
  4. Multi-Environment:
    • How are APP_NAME and config/backup.php configured per environment (e.g., staging vs. production)?
    • Are there disk/connection differences between backup storage (e.g., S3) and restore targets (e.g., local DB)?

Integration Approach

Stack Fit

  • Laravel-Centric: Optimized for Laravel 12+ with PHP 8.4+. No framework-agnostic layers.
  • Backup Ecosystem: Hard dependency on spatie/laravel-backup (v9+). No alternative backup formats supported.
  • Storage Agnostic: Works with any disk configured in config/backup.php (local, S3, FTP, etc.).
  • Database Support: Tested with MySQL, PostgreSQL, and SQLite. No SQL Server/Oracle support.

Migration Path

  1. Prerequisite Check:
    • Verify spatie/laravel-backup (v9+) is installed and configured.
    • Upgrade Laravel/PHP if below requirements (12/8.4).
  2. Installation:
    composer require wnx/laravel-backup-restore
    php artisan vendor:publish --tag="backup-restore-config"
    
  3. Configuration:
    • Ensure config/backup.php has correct disks, sources, and encryption settings.
    • Validate APP_NAME matches the backup folder naming convention.
  4. Testing:
    • Run php artisan backup:restore --dry-run (if supported) or test in a staging environment.
    • Validate health checks (default: table existence; custom checks if added).

Compatibility

  • Backward Compatibility: Breaking changes in v1.4.0 dropped support for Laravel 10/PHP 8.1. Upgrade path required.
  • Backup Format: Only restores backups created by spatie/laravel-backup. Incompatible with raw SQL dumps or other tools.
  • Compression: Supports .sql, .sql.gz, and .sql.bz2 (added in v1.2.0). Older backups may fail if uncompressed.
  • CI/CD: Designed for automation (e.g., GitHub Actions workflow provided). Requires secrets management for encryption keys.

Sequencing

  1. Pre-Restore:
    • Backup the current database (if critical data exists) or wipe it (--reset flag).
    • Verify disk permissions for backup storage (e.g., S3 IAM roles).
  2. Restore Execution:
    • Use --backup=latest for simplicity or specify a path (e.g., --backup=backups/production/2024-05-01.sql.gz).
    • For automation, include --no-interaction and all required flags (disk, connection, password).
  3. Post-Restore:
    • Run health checks (custom or default).
    • Test critical workflows (e.g., API endpoints, admin panels).
    • Clean up temporary files (--keep flag for debugging).

Operational Impact

Maintenance

  • Dependency Updates:
    • Monitor wnx/laravel-backup-restore and spatie/laravel-backup for breaking changes (e.g., Laravel 13 support).
    • PHP 8.4+ is required; future PHP versions may need updates.
  • Configuration Drift:
    • config/backup.php and config/laravel-backup-restore.php must stay in sync across environments.
    • APP_NAME must match backup folder naming conventions.
  • Encryption Key Rotation:
    • If backup encryption keys change, all backups become unrecoverable without the old key.

Support

  • Troubleshooting:
    • Common Issues:
      • NoDatabaseDumpsFound: Verify --disk and backup paths.
      • GTID errors: Add --set-gtid-purged=OFF to backup config.
      • Permission denied: Check disk credentials (e.g., S3 IAM roles).
    • Logs: Artisan commands output progress; enable Laravel debugging for errors.
  • Custom Health Checks:
    • Extending health checks requires PHP knowledge. Example provided in README.
    • Failed checks block restore completion; design checks to be idempotent.

Scaling

  • Performance:
    • Large databases may time out during restore. The package disables process timeouts by default.
    • Parallel restores: Not supported; run one restore at a time.
  • Multi-Region:
    • Backup storage (e.g., S3) should be low-latency to the restore environment.
    • Cross-region restores may hit network bottlenecks.
  • High Availability:
    • Restores are blocking; schedule during low-traffic periods.
    • For zero-downtime, use blue-green deployments with separate DB instances.

Failure Modes

Failure Scenario Impact Mitigation
Corrupted backup file Restore fails silently or partially Validate backups with spatie/laravel-backup:verify or GitHub Actions workflow.
Incorrect decryption key Backup decryption fails Use --password flag or ensure config/backup.php keys are correct.
GTID/replication conflicts MySQL restore fails Pre-backup: Add --set-gtid-purged=OFF to config/backup.php.
Disk permissions denied Backup download fails Verify IAM roles (S3), filesystem permissions (local), or credentials.
Schema drift (backup vs. target DB) SQL syntax errors Test restores in staging; use --reset to wipe target DB first.
Health check failures Restore marked as failed Review custom health checks; ensure they’re non-destructive.

Ramp-Up

  • Developer Onboarding:
    • 10–15 mins: Install and configure the package.
    • 30 mins: Test a restore in a staging environment.
    • 1 hour: Implement custom health checks (if needed).
  • Documentation Gaps:
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.
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope