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 Db Snapshots Laravel Package

spatie/laravel-db-snapshots

Laravel package that adds Artisan commands to quickly create, load, list, and clean up database snapshots (dumps) for your app. Works with MySQL, PostgreSQL, and SQLite—ideal for resetting state in development or tests.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Database-driven feature development: Enables rapid iteration by saving/restoring database states, accelerating testing and debugging of database-heavy features (e.g., migrations, complex queries, or data pipelines).
  • CI/CD pipeline optimization: Reduces test suite execution time by allowing teams to snapshot a "clean" database state and reuse it across test runs, cutting down on repetitive setup/teardown.
  • Build vs. buy: Eliminates the need to build custom database backup/restore scripts or rely on third-party tools (e.g., mysqldump, pg_dump), saving engineering time and reducing technical debt.
  • Use cases:
    • Testing: Isolate test environments by loading snapshots of production-like data (e.g., for edge-case testing).
    • Local development: Quickly reset a local database to a known state (e.g., after a failed migration or data corruption).
    • Data migration validation: Compare snapshots before/after migrations to verify data integrity.
    • On-call debugging: Restore a database to a pre-incident state for root-cause analysis.
    • Multi-environment parity: Ensure staging/production data structures align by loading identical snapshots.

When to Consider This Package

  • Adopt if:

    • Your Laravel application relies on complex database schemas or large datasets (>100MB) where manual mysqldump/pg_dump is cumbersome.
    • Your team frequently encounters flaky tests due to database state inconsistencies.
    • You need to exclude/include specific tables (e.g., for GDPR compliance or performance testing).
    • Your CI/CD pipeline struggles with slow database setup/teardown (e.g., Dockerized tests).
    • You require compressed snapshots to save storage space or reduce transfer times.
    • Your team uses multiple database connections (e.g., MySQL + PostgreSQL) and needs to manage snapshots per connection.
  • Look elsewhere if:

    • You need incremental backups (this package creates full snapshots).
    • Your database is too large (>1GB) for local storage or streaming (consider cloud-based solutions like AWS RDS snapshots).
    • You require point-in-time recovery (e.g., restoring to a specific transaction).
    • Your team lacks Laravel expertise (this is a Laravel-specific tool).
    • You need cross-platform compatibility beyond MySQL, PostgreSQL, and SQLite (e.g., Oracle, SQL Server).
    • You’re already using a dedicated backup tool (e.g., Percona XtraBackup, Barman) with tighter integration into your workflow.

How to Pitch It (Stakeholders)

For Executives:

"This package lets our engineering team save and restore database states in seconds—like hitting ‘undo’ for our entire database. For example, if a developer breaks a migration or needs to test a complex query with production-like data, they can snapshot the current state, make changes, and revert instantly. This cuts debugging time by 30–50% and reduces the risk of environment drift in CI/CD. It’s a low-cost, high-impact tool that aligns with our goals for faster iteration and reliable deployments."

ROI:

  • Reduces on-call incidents tied to database corruption.
  • Accelerates feature development by eliminating manual data setup.
  • Lowers cloud costs by reusing snapshots instead of spinning up fresh databases.

For Engineering/DevOps:

*"This is a Swiss Army knife for database management in Laravel. Key benefits:

  • Artisan commands for snapshot creation/loading (e.g., php artisan snapshot:create prod-like-data).
  • Selective backups: Exclude sensitive tables (e.g., users) or include only critical ones (e.g., orders, products).
  • CI/CD integration: Snapshots can be stored in S3/artifacts and loaded in parallel test runs, slashing test suite time.
  • Events hooks: Extend functionality (e.g., trigger Slack alerts when a snapshot is loaded).
  • Supports streaming: Load large snapshots without memory issues.

Example workflow:

  1. Dev creates a snapshot of a buggy state: snapshot:create buggy-state.
  2. QA loads it in staging: snapshot:load buggy-state --connection=staging.
  3. After fixing, cleanup old snapshots: snapshot:cleanup --keep=5.

Alternatives considered:

  • Custom scripts: Fragile, hard to maintain.
  • Third-party tools: Overkill for Laravel-specific needs.
  • No solution: Manual mysqldump is error-prone and slow.

Next steps:

  • Add to composer.json and configure the snapshots disk.
  • Document snapshot naming conventions (e.g., feature-x-prod-2024-05-20).
  • Explore integrating with our backup rotation policy."*
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.
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
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
ecotone/kafka
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata