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 | simple3 '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 naminggfswithout 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 (nulldisables).max_storage_megabytes— once the kept set would exceed this total size, the oldest kept backups are dropped until it fits (nulldisables). (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-run2php 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);