-
-
Notifications
You must be signed in to change notification settings - Fork 782
Runtime reload configuration #1905
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
base: main
Are you sure you want to change the base?
Conversation
…ancy environment and the command is called from another command and the config has been changed.
@freekmurze Would you like to take a look at this PR? Thank you! |
Any updates here? @freekmurze |
Could you add a test to prove that the option works. Could you also update the docs? |
Thanks for your PR — it pointed me in the right direction. Here are a couple of suggestions:
protected $signature = 'backup:run {--filename=} {--only-db} {--db-name=*} {--only-files} {--only-to-disk=} {--disable-notifications} {--timeout=} {--tries=} {--reload-config=}';
...
public function handle(): int
{
if ($this->option('reload-config')) {
$this->config = Config::fromArray(config($this->option('reload-config') ?? 'backup'));
}
...
}
|
Merge with main repository
- Added test - Added documentation
@freekmurze I've updated the PR, added documentation and a test |
docs/taking-backups/overview.md
Outdated
|
||
foreach ($tenants as $tenant) { | ||
config(['backup.backup.destination.filename_prefix' => $tenant.'_']); | ||
$this->call('backup:run', ['--timeout' => 120, '--config' => 'backup']); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm afraid I don't understand the example fully.
I was expecting that you could use another back config with something like this
php artisan backup:run --config=tenant1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe better (my use-case):
Running Backups with Specific Configuration
If you want to back up different areas of your Laravel application separately – for example with different schedules, database connections, filesystem disks, or cleanup settings – you can create custom backup configuration files.
Example:
Additional config files placed in the config/
directory:
config/backup_database.php
config/backup_invoices.php
config/backup_uploads.php
You can then run backups and cleanup commands individually:
php artisan backup:run --config=backup_database
php artisan backup:clean --config=backup_database
php artisan backup:run --config=backup_invoices
php artisan backup:clean --config=backup_invoices
php artisan backup:run --config=backup_uploads
php artisan backup:clean --config=backup_uploads
This allows full flexibility in scheduling, retention, and target destinations for each backup scope.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another example is a multitenant site with multiple databases.
When running the backup I loop through all the tenants and need to reload the tenant db configuration and also specify a different backup.filename_prefix in order to save each backup in a subfolder with the tenant name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@steffensatrapa Thanks for your addition!
@freekmurze Is that example clear? In that case I will add it to the documentation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any updates here? @freekmurze
See discussion: #1900
Added an option to reload the configuration. For e.g. when used in a multi tenancy environment where the command is called from another command and the config has been changed for the specific tenant.