spatie/db-dumper
A PHP package for dumping MySQL, MariaDB, PostgreSQL, SQLite, and MongoDB databases with a fluent API. It wraps native tools like mysqldump and pg_dump, letting you write a dump straight to a file in just a few lines of code.
Architecture fit
spatie/db-dumper is a thin command-builder, not a database client. It does not open connections via PDO or the Laravel DB manager; it composes a shell command string for the native dump binaries (mysqldump, mariadb-dump, pg_dump, sqlite3, mongodump) and executes it through symfony/process, optionally piping through gzip/bzip2. That makes it a good fit for a Laravel app that already owns connection configuration, and a poor fit anywhere we expect a self-contained backup agent. The integration work is therefore not "call the library" — it is "build a small adapter that maps config('database.connections.*') (or a DATABASE_URL) onto the dumper's fluent setters, and owns output location, retention, and verification."
Integration feasibility
High. composer require spatie/db-dumper is additive, framework-agnostic, and the API surface is small and stable (create → credentials/host/db → options → dumpToFile()). It is the engine underneath spatie/laravel-backup, which is a meaningful real-world validation path. The real feasibility constraint is infrastructural, not code: the binaries must exist in the runtime image and be version-compatible with the target servers. In containerised deployments this is a Dockerfile change (client packages + gzip) plus an image-size/attack-surface trade-off.
Technical risk
mysqldump 8 against MySQL 5.7 fails on column_statistics (the README documents doNotUseColumnStatistics() as the workaround); pg_dump must be at or above the server major version. Managed services (RDS/Aurora/Cloud SQL) may not grant the privileges mysqldump/pg_dump want (PROCESS, LOCK TABLES, broad read), silently producing incomplete dumps rather than errors.setPassword() surfaces in the command line / process listing. The getDumpCommand($dumpFile, $credentialsFile) path exists precisely to avoid this; we should standardise on it, and own the temp-file permissions and cleanup.includeTables/excludeTables accept strings/arrays that end up in a shell command. If any of those values ever derive from tenant or user input, we need an allowlist and a pinned, audited version.--single-transaction vs LOCK TABLES) and on storage engine (MyISAM has no transaction-consistent snapshot regardless).laravel-backup, and a last release dated in the future. Treat the scores as directional only and confirm versions/activity against Packagist before committing.Key questions
Stack fit
Native Laravel/PHP fit: Composer install, no service to run, no schema, no migrations, no framework coupling. It slots into an existing Laravel app as a library. If spatie/laravel-backup is already present, the package is already in the dependency tree and version alignment is free. Where we need a scheduler, Laravel's console scheduler + queue is sufficient; no new infrastructure.
Migration path Low friction and reversible. Typical starting points and their path:
exec('mysqldump …') → replace the string-building and exec with the fluent builder; behaviour is equivalent, but we gain consistent option handling, the credentials-file pattern, and a testable API. Keep the scripts until the new path has produced verified restores.laravel-backup end-to-end → keep it if it fits; only drop to db-dumper directly if we need control it doesn't expose (per-tenant dumps, custom naming, custom storage routing, cross-region upload).In all cases the package is added behind our own DatabaseDumper interface (factory returning a configured dumper per connection), so the vendor type appears in exactly one place and can be swapped (e.g. to mydumper or a managed snapshot API) without touching call sites.
Compatibility
mysql-client / mariadb-client, postgresql-client, sqlite3, mongodump, gzip). Watch Alpine vs Debian package naming and the MariaDB-client-as-mysqldump substitution — flags differ at the margins.Compressor interface is two methods, so adding zstd is trivial — but note the pipefail caveat above before enabling any compressor.Sequencing
DatabaseDumperFactory mapping Laravel connection config and DATABASE_URL to dumper instances; centralise options (single-transaction, routines, excluded log/session tables, excludeTablesData for noisy tables).dumpToFile() writing to a temp name, never the final artefact.gunzip -t where compressed), and ideally a periodic automated restore into a throwaway schema with row-count sanity checks.Maintenance Light and mostly external. MIT licence, Spatie-maintained, small API, active release cadence (changelog, tagged releases). Pin to a minor version and review the changelog on bump — 2.13.1 is a good example of a patch that changes runtime failure semantics. The ongoing maintenance burden is not the PHP package; it is the client binaries in the image (patching cadence, CVE response, image size) and the alignment of those binaries with server versions as databases are upgraded.
Support
No commercial SLA. Self-support via GitHub issues, plus the practical benefit that laravel-backup exercises the same code path, so bugs surface widely and quickly. Bus factor is a small core team; the mitigation is the thin API — if the project stalled, replacing it with our own command builder is a contained piece of work behind the adapter interface. Do not let Spatie\DbDumper\* types leak across the codebase.
Scaling Dumps are single-threaded and bound by DB read throughput, network, and compression CPU. Cost grows roughly linearly with data volume, and per-tenant dumping multiplies both load and file count. Practical ceilings to plan against: connection and query timeouts on long dumps, PHP/queue worker timeouts (run dumps in a queued job with an explicit long timeout, never in a web request), local disk on the app node (dump to a dedicated volume or stream to object storage), and storage/egress growth under retention. If a database can't complete a logical dump inside the window, the answer is parallel dump tooling or storage-level snapshots — plan that as a known exit ramp rather than discovering it at 3am.
Failure modes
Ramp-up
Low for a mid-level PHP developer: the fluent API is self-documenting and a working dump is under an hour. The genuine ramp-up is operational — knowing which binaries and grants each engine needs, how to run a restore, how to read a mysqldump/pg_dump failure, and how the pipeline's verification gates work. Budget a day of ops-oriented documentation and a restore walkthrough per engine, and assume the first production-shaped run will surface privilege or version issues the dev environment hid.
How can I help you explore Laravel packages today?