Primo Committ
This commit is contained in:
4
vendor/spatie/laravel-backup/docs/cleaning-up-old-backups/_index.md
vendored
Normal file
4
vendor/spatie/laravel-backup/docs/cleaning-up-old-backups/_index.md
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
---
|
||||
title: Cleaning up old backups
|
||||
weight: 2
|
||||
---
|
||||
26
vendor/spatie/laravel-backup/docs/cleaning-up-old-backups/events.md
vendored
Normal file
26
vendor/spatie/laravel-backup/docs/cleaning-up-old-backups/events.md
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
---
|
||||
title: Events
|
||||
weight: 2
|
||||
---
|
||||
|
||||
These events are fired during the cleanup process.
|
||||
|
||||
## CleanupWasSuccessful
|
||||
|
||||
`Spatie\Backup\Events\CleanupWasSuccessful`
|
||||
|
||||
This event is fired when old backups are successfully removed from a destination filesystem.
|
||||
|
||||
It has one public property `$backupDestination` that contains an instance of `Spatie\Backup\BackupDestination\BackupDestination`.
|
||||
|
||||
## CleanupHasFailed
|
||||
|
||||
`Spatie\Backup\Events\CleanupHasFailed`
|
||||
|
||||
This event is fired when something goes wrong while cleaning up.
|
||||
|
||||
It has two public properties:
|
||||
|
||||
- `$exception`: an object that conforms to the `Exception` interface. It is highly likely that `$exception->getMessage()` will return more information on what went wrong.
|
||||
- `$backupDestination`: if this is `null` then something probably went wrong before even connecting to one of the backup destinations. If it is an instance of `Spatie\Backup\BackupDestination\BackupDestination` something went wrong when trying to connect or
|
||||
write to that destination.
|
||||
111
vendor/spatie/laravel-backup/docs/cleaning-up-old-backups/overview.md
vendored
Normal file
111
vendor/spatie/laravel-backup/docs/cleaning-up-old-backups/overview.md
vendored
Normal file
@@ -0,0 +1,111 @@
|
||||
---
|
||||
title: Cleaning up old backups
|
||||
weight: 1
|
||||
---
|
||||
|
||||
Over time the number of backups and the storage required to store them will grow. At some point you will want to clean up old backups.
|
||||
|
||||
You can clean up your backups by running:
|
||||
|
||||
```bash
|
||||
php artisan backup:clean
|
||||
```
|
||||
|
||||
We'll tell you right off the bat that the package by default will never delete the latest backup regardless of its size or age.
|
||||
|
||||
## Determining which backups should be deleted
|
||||
|
||||
This portion of the configuration determines which backups should be deleted.
|
||||
|
||||
```php
|
||||
//config/backup.php
|
||||
|
||||
'cleanup' => [
|
||||
/*
|
||||
* The strategy that will be used to cleanup old backups. The default strategy
|
||||
* will keep all backups for a certain amount of days. After that period only
|
||||
* a daily backup will be kept. After that period only weekly backups will
|
||||
* be kept and so on.
|
||||
*
|
||||
* No matter how you configure it the default strategy will never
|
||||
* deleted the newest backup.
|
||||
*/
|
||||
'strategy' => \Spatie\Backup\Tasks\Cleanup\Strategies\DefaultStrategy::class,
|
||||
|
||||
'default_strategy' => [
|
||||
|
||||
/*
|
||||
* The number of days that all backups must be kept.
|
||||
*/
|
||||
'keep_all_backups_for_days' => 7,
|
||||
|
||||
/*
|
||||
* The number of days that all daily backups must be kept.
|
||||
*/
|
||||
'keep_daily_backups_for_days' => 16,
|
||||
|
||||
/*
|
||||
* The number of weeks of which one weekly backup must be kept.
|
||||
*/
|
||||
'keep_weekly_backups_for_weeks' => 8,
|
||||
|
||||
/*
|
||||
* The number of months of which one monthly backup must be kept.
|
||||
*/
|
||||
'keep_monthly_backups_for_months' => 4,
|
||||
|
||||
/*
|
||||
* The number of years of which one yearly backup must be kept.
|
||||
*/
|
||||
'keep_yearly_backups_for_years' => 2,
|
||||
|
||||
/*
|
||||
* After cleaning up the backups remove the oldest backup until
|
||||
* this amount of megabytes has been reached.
|
||||
*/
|
||||
'delete_oldest_backups_when_using_more_megabytes_than' => 5000,
|
||||
],
|
||||
],
|
||||
```
|
||||
|
||||
This package provides an opinionated method to determine which old backups should be deleted. We call this the `DefaultStrategy`. This is how it works:
|
||||
|
||||
- Rule #1: it will never delete the latest backup regardless of its size or age
|
||||
- Rule #2: it will keep all backups for the number of days specified in `keepAllBackupsForDays`
|
||||
- Rule #3: it will only keep daily backups for the number of days specified in `keepDailyBackupsForDays` for all backups
|
||||
older than those covered by rule #2
|
||||
- Rule #4: it will only keep weekly backups for the number of months specified in `keepMonthlyBackupsForMonths` for all backups older than those covered by rule #3
|
||||
- Rule #5: it'll only keep yearly backups for the number of years specified in `keepYearlyBackupsForYears` for all backups older than those covered by rule #4
|
||||
- Rule #6: it will start deleting old backups until the volume of storage used is lower than the amount specified in `deleteOldestBackupsWhenUsingMoreMegabytesThan`.
|
||||
|
||||
Of course the numbers used in the default configuration can be adjusted to suit your own needs.
|
||||
|
||||
## Creating your own strategy
|
||||
|
||||
If you're requirements are not covered by the `DefaultStrategy`, you can create your own custom strategy.
|
||||
|
||||
Extend the abstract class `Spatie\Backup\Tasks\Cleanup\CleanupStrategy`. You only need to implement this method:
|
||||
|
||||
```php
|
||||
use Spatie\Backup\BackupDestination\BackupCollection;
|
||||
|
||||
public function deleteOldBackups(BackupCollection $backupCollection)
|
||||
```
|
||||
|
||||
The `BackupCollection` class is extended from `Illuminate\Support\Collection` and contains `Spatie\Backup\BackupDestination\Backup` objects sorted by age. The latest backup is the first one in the collection.
|
||||
|
||||
Using the collection, you can easily manually delete the oldest backup:
|
||||
|
||||
```php
|
||||
// Retrieve an instance of `Spatie\Backup\BackupDestination\Backup`
|
||||
$backup = $backups->oldestBackup();
|
||||
|
||||
// Bye bye backup
|
||||
$backup->delete();
|
||||
```
|
||||
|
||||
Don't forget to specify the full classname of your custom strategy in the `cleanup.strategy` key of the `laravel-backup` config file.
|
||||
|
||||
## Get notifications when a cleanup goes wrong
|
||||
|
||||
You can receive a notification when a cleanup goes wrong. Read the section on [notifications](/laravel-backup/v5/sending-notifications/overview) for more info.
|
||||
Reference in New Issue
Block a user