spatie/db-dumper
PHP database dump utility supporting MySQL, MariaDB, PostgreSQL, SQLite, and MongoDB. Wraps native tools (mysqldump, mariadb-dump, pg_dump, sqlite3, mongodump) with a simple fluent API to export databases to SQL or gz files.
Database Migration & Backup Automation:
Enable automated, programmatic database backups for Laravel applications, reducing reliance on manual mysqldump/pg_dump commands. Critical for CI/CD pipelines, disaster recovery, and environment parity (e.g., staging → production).
Selective Data Export: Support granular backups (e.g., excluding logs, sessions, or specific tables) to optimize storage and reduce noise in test environments. Aligns with data privacy/compliance needs (e.g., GDPR).
Multi-Environment Sync:
Facilitate schema/data synchronization across dev/staging/prod by skipping AUTO_INCREMENT values to avoid primary key conflicts during imports.
Roadmap: Self-Service Data Tools: Build a "data export" feature for end-users (e.g., admins downloading their own data subsets) by exposing controlled dump endpoints via Laravel routes.
Build vs. Buy: Buy: Avoid reinventing CLI-based dump logic. Spatie’s package handles edge cases (e.g., MySQL 5.7 compatibility, compression) and supports MongoDB/SQLite—reducing dev effort. Build: Only if needing custom dump logic (e.g., real-time streaming dumps) or integrating with proprietary DBs.
Adopt if:
Look elsewhere if:
mysqldump, pg_dump, etc.)—this package delegates to them."This package lets us automate database backups and exports programmatically within Laravel, eliminating manual mysqldump commands and reducing human error. It supports all our databases (MySQL, PostgreSQL, MongoDB) and enables features like selective data exports—critical for compliance and user-controlled data access. With minimal dev effort, we gain reliability, consistency, and scalability for backups, migrations, and even customer data portability."
Key Outcomes:
*"Spatie’s db-dumper is a battle-tested Laravel package that wraps native CLI tools (mysqldump, pg_dump) with a clean PHP API. It handles edge cases (e.g., MySQL 5.7 compatibility, compression) and supports selective dumps—perfect for:
AUTO_INCREMENT to avoid PK conflicts.Why not build it?
Trade-offs:
mysqldump, etc.) on the server.Proposal: Use this for all Laravel database backups/exports. Integrate with:
App\Jobs\DumpDatabase) for nightly backups.How can I help you explore Laravel packages today?