Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

notes for spatie/laravel-backup #101

Closed
ctf0 opened this issue Jan 16, 2021 · 1 comment
Closed

notes for spatie/laravel-backup #101

ctf0 opened this issue Jan 16, 2021 · 1 comment

Comments

@ctf0
Copy link

ctf0 commented Jan 16, 2021

i couldn't find any tickets/comments regarding it, so i thought i would add what i've found to help others.

so far no changes needed except for the cmnd scheduling.

  1. using arg like --only-db wont work "this is mostly related to how tenancy handle cmnds with args like that" ex.
  • --option="only-db"
  • --only-db
  • --option="--only-db"
  1. make sure to use ->withoutOverlapping(); or the db dump cmnd will overlap each other.

  2. if u r going to schedule both central & tenant backup, do it on a different interval or the db dump cmnd will overlap each other.

    • however if its imperative that both run on a close interval as possible u can instead try
      $schedule->exec('php artisan backup:run && php artisan tenants:run backup:run' . $this->getTenants())->everyMinute()->runInBackground()->withoutOverlapping();
  3. as for $this->getTenants() check Schedule Run support archtechx/tenancy#502 (comment)

@ctf0
Copy link
Author

ctf0 commented Jan 20, 2021

thanx to spatie/laravel-backup#167 (comment) it seems that when running the cmnd through tenant, the db is not correctly set, so to fix that

  1. append a listener to Events\TenancyInitialized::class
  2. inside it add
foreach (config('backup.backup.source.databases') as $connection) {
    config(["database.connections.$connection.database" => $event->tenancy->tenant->db_name]);
}
  1. test php artisan tenants:run backup:run

@stancl stancl mentioned this issue Jun 4, 2022
@stancl stancl closed this as completed Jun 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants