stefanzweifel / laravel-backup-restore

A package to restore database backups made with spatie/laravel-backup.
https://stefanzweifel.dev/posts/2023/06/15/introducing-laravel-backup-restore
MIT License
165 stars 15 forks source link

multiple database backups not restored correctly #52

Open tjhunkin-inhance opened 10 months ago

tjhunkin-inhance commented 10 months ago

I use Spatie Multitenancy which requires a landlord and tenant database.

This package tries to restore the dump file of the landlord database into the tenant database in MySql->getImportCommand

Spatie Backup allows the specification of multiple databases in the backup config.

You would need to do a contains or something checking the database name in the connections versus the dumped databases to match which restores where.

stefanzweifel commented 10 months ago

Sorry for my late reply on this issue; I was off the internet for the past 2 weeks.


I haven't used spatie/laravel-multitenancy yet, so I don't know how the package works.

Solving this issue sounds complicated to be honest. I think the best user experience would be, that you as a user can select which db-dump is being imported into which database connection. (Imagine being prompted to select the database connection in the CLI)

But when should this logic trigger? Should the package check if the host application has spatie/laravel-multitenancy installed? What about stancl/tenancy? Does the package then have to behave differently for each tenancy flavour?

I'm currently not tackling this issue as I can't see a good solution for this. However, I'm more than happy to discuss potential solutions here in public and will leave this issue open for a certain amount of time.

tjhunkin-inhance commented 10 months ago

Perhaps the user can specify a flag like --multiple-databases or detect multiple SQL files in the backup, but then you can only restore one database at a time by specifying the connection and a dump name.