nyoncode/laravel-backup-manager

nyoncode/laravel-backup-manager

Powerful and extensible backup manager for Laravel applications: databases, files, encryption, integrity manifests and multi-destination storage.

0
Packagist stažení
0
Verzí
1.1.1
Aktuální verze
Závislosti
php ^8.3 ext-json * ext-openssl * illuminate/bus ^12.0|^13.0 illuminate/console ^12.0|^13.0 illuminate/contracts ^12.0|^13.0 illuminate/database ^12.0|^13.0 illuminate/filesystem ^12.0|^13.0 illuminate/queue ^12.0|^13.0 illuminate/support ^12.0|^13.0 nyoncode/laravel-package-toolkit ^2.1.1 symfony/finder ^7.0 symfony/process ^7.0

Databases

Backup Manager backs up your databases by running each engine's own dump tool (such as mysqldump) for you — there's no SQL to write. MySQL, MariaDB, PostgreSQL and SQLite work out of the box, and you can teach it new engines (see Extending).

Supported drivers

Driver Config value Dump tool Restore tool
MySQL mysql mysqldump mysql
MariaDB mariadb mysqldump mysql
PostgreSQL pgsql pg_dump psql
SQLite sqlite file copy file copy

The driver is taken directly from your Laravel connection config, so no extra mapping is needed.

Choosing connections

1'databases' => [
2 'connections' => ['mysql', 'reporting'], // [] = the default connection
3],

An empty array backs up config('database.default').

Excluding tables

1'databases' => [
2 'exclude_tables' => ['telescope_entries', 'failed_jobs'],
3 'schema_only_tables' => ['sessions', 'cache'],
4],
  • exclude_tables — omitted entirely (no structure, no data).
  • schema_only_tables — structure is dumped, rows are not. Ideal for large, regenerable tables (sessions, cache, telescope). The structure is still dumped with DROP TABLE IF EXISTS so restores remain idempotent.

Security of credentials

Passwords are never placed on the command line (where they would be visible in the host's process list). They are passed through the environment:

  • MySQL/MariaDB → MYSQL_PWD
  • PostgreSQL → PGPASSWORD

PostgreSQL client version

Use a pg_dump / psql whose version is less than or equal to the server version. A newer client emits configuration settings (e.g. transaction_timeout, added in PostgreSQL 17) that an older server rejects when the dump is restored. When in doubt, point the binaries at a version-matched client:

1'binaries' => [
2 'pg_dump' => '/usr/lib/postgresql/16/bin/pg_dump',
3 'psql' => '/usr/lib/postgresql/16/bin/psql',
4],

How SQLite is handled

SQLite databases are snapshotted with a byte-for-byte file copy, which preserves the schema, data and pragmas exactly. In-memory databases cannot be backed up.

Binaries

If mysqldump / pg_dump are not on the PATH, configure absolute paths:

1'binaries' => [
2 'mysqldump' => '/usr/local/opt/mysql-client/bin/mysqldump',
3 'pg_dump' => '/usr/local/opt/postgresql@16/bin/pg_dump',
4],

Database-only backups

Set the profile type to database to skip files entirely:

1'profiles' => [
2 'db-hourly' => ['type' => 'database', 'destinations' => ['s3']],
3],