nyoncode/laravel-backup-manager

nyoncode/laravel-backup-manager

Powerful and extensible backup manager for Laravel applications: databases, files, encryption, integrity manifests and multi-destination storage.

0
Packagist stažení
0
Verzí
1.1.1
Aktuální verze
Závislosti
php ^8.3 ext-json * ext-openssl * illuminate/bus ^12.0|^13.0 illuminate/console ^12.0|^13.0 illuminate/contracts ^12.0|^13.0 illuminate/database ^12.0|^13.0 illuminate/filesystem ^12.0|^13.0 illuminate/queue ^12.0|^13.0 illuminate/support ^12.0|^13.0 nyoncode/laravel-package-toolkit ^2.1.1 symfony/finder ^7.0 symfony/process ^7.0

Retention

Left alone, backups pile up until they fill the disk. Retention is the policy that decides which historical backups to keep and removes the rest. You apply it with php artisan backup:clean, by hand or on a schedule.

1'retention' => [
2 'strategy' => 'gfs', // gfs | simple
3 'gfs' => ['keep_daily' => 7, 'keep_weekly' => 4, 'keep_monthly' => 6, 'keep_yearly' => 2],
4 'simple' => ['keep_latest' => 10],
5 'max_age_days' => 365,
6 'max_storage_megabytes' => null,
7],

Strategies

GFS (Grandfather-Father-Son)

Pro feature. GFS retention requires Backup Manager Pro. The free core provides simple; a policy naming gfs without Pro prunes nothing (fail-closed) rather than falling back to a different strategy.

Keeps the newest backup of each of the last N days, weeks, months and years, producing a tapering history — dense recent, sparse old. With the defaults above you keep the last 7 days, then one per week for 4 weeks, one per month for 6 months, and one per year for 2 years.

Simple

Keeps the newest N backups and deletes the rest:

1'retention' => ['strategy' => 'simple', 'simple' => ['keep_latest' => 10]],

Additional caps

Applied on top of the chosen strategy:

  • max_age_days — nothing older than this is kept (null disables).
  • max_storage_megabytes — once the kept set would exceed this total size, the oldest kept backups are dropped until it fits (null disables). (Pro — the free core does not enforce the size cap.)

Per-profile overrides

A profile can override retention:

1'profiles' => [
2 'hourly' => [
3 'type' => 'database',
4 'retention' => ['strategy' => 'simple', 'simple' => ['keep_latest' => 48]],
5 ],
6],

Previewing

Use --dry-run to see what would be deleted without deleting anything:

1php artisan backup:clean --dry-run
2php artisan backup:clean --profile=nightly --disk=s3

Retention is applied to every destination of the profile (or just --disk).

Programmatic use

1use Nyoncode\BackupManager\DTOs\RetentionPolicy;
2use Nyoncode\BackupManager\Managers\RetentionManager;
3 
4$policy = RetentionPolicy::fromConfig(config('backup-manager.retention'));
5$deleted = app(RetentionManager::class)->apply('s3', 'backups', $policy, dryRun: true);