spatie / laravel-backup

A package to backup your Laravel app
https://spatie.be/docs/laravel-backup
MIT License
5.64k stars 763 forks source link

Add config option database_dump_file_use_connection_name #1785

Closed jbraband closed 5 months ago

jbraband commented 6 months ago

_Code and tests are added. Documentation update was omitted because a similar config database_dump_file_timestamp_format is not documented. I'm happy to add documentation should that be required for a merge._

This PR adds a config option at config('backup.backup.database_dump_file_use_connection_name') of type boolean, defaulting to null and thus uses the database name as it always has.

This config, if set to true, uses the connection's key from config('database.connections') in the dump file name instead of the database name

Use Case I have 2 connections defined to the same database, each with different db-dumper options. I have one to dump only the schema (see my PR to spatie/db-dumper#208) and a second to dump the data of the database, minus the data from large tables (large as in disk space) that I can recreate.

As the package stand now, it names the dump files for these 2 connections the same based on the database name and I only get one file in the zipped archive.

With this PR, I now have both files in the zipped archive, one for each connection.

I'm happy to make any recommended modifications or additions!

Edited for grammar and clarity

freekmurze commented 5 months ago

Thanks for this!

Could you also add docs?

jbraband commented 5 months ago

Thanks for this!

Could you also add docs?

Docs added. I also added docs for database_dump_file_timestamp_format which were missing.

freekmurze commented 5 months ago

Thanks!