SafeGuard

Retention Policies

Control how many backups SafeGuard keeps, when old backups are deleted, and how to optimize storage costs across schedules.

What Are Retention Policies?

Every backup you create consumes storage space. Without a retention policy, backups accumulate indefinitely until you run out of disk space or hit your cloud storage quota. Retention policies solve this by automatically removing old backups based on rules you define.

Retention policies help you:

  • Control storage costs — cloud storage bills scale with the number and size of backups you keep.
  • Reduce clutter — dozens of outdated backups make it harder to find the restore point you need.
  • Meet compliance requirements — some industries require data to be retained for a specific number of days, while others require deletion after a maximum period.
  • Protect incremental chains — SafeGuard handles chain dependencies so you never lose the ability to restore.

Retention Settings

SafeGuard provides two layers of retention control: global settings that apply site-wide, and per-schedule retention that lets you fine-tune each schedule independently.

Global Settings

These settings are found under SafeGuard → Settings → Retention.

SettingDefaultDescription
Backup limit20Maximum number of completed backups to keep across all manual backups. Set to unlimited to disable.
Auto-delete old backupsEnabledAutomatically removes backups that exceed the retention limit. When disabled, you must delete old backups manually.
Delete by ageDisabledWhen enabled, deletes backups older than a specified number of days instead of using a count-based limit.
Delete local copy after uploadDisabledRemoves the local backup file after it has been successfully uploaded to a remote storage provider. Saves server disk space.
Storage limit warningEnabledSends an email notification when storage usage approaches capacity.

Per-Schedule Retention

Each schedule has its own independent retention policy with two modes:

ModeDescriptionExample
Keep by countKeeps the N most recent backups for this schedule. Oldest are deleted first.Keep 30 daily backups
Keep by age (days)Keeps backups created within the last N days. Anything older is deleted.Keep backups from the last 90 days

Per-schedule retention is the recommended approach. It lets you keep more frequent backups for critical schedules (like database snapshots) while keeping fewer for less critical ones (like weekly full backups).

Configuring Retention

Global Retention Settings

Open Retention Settings

Navigate to SafeGuard → Settings and select the Retention tab.

Set your backup limit

Enter the maximum number of backups to keep. The default is 20. Set to unlimited if you want to manage deletion manually.

Configure auto-delete behavior

Toggle Auto-delete old backups on to have SafeGuard automatically remove excess backups. Optionally enable Delete by age to use a time-based policy instead of a count.

Save settings

Click Save Changes to apply the new retention policy.

Per-Schedule Retention

Open the schedule

Go to SafeGuard → Schedules and click on the schedule you want to configure (or create a new one).

Set retention mode

Under the Retention section, choose either Keep by count or Keep by age (days).

Set the retention value

Enter the number of backups to keep (count mode) or the number of days to retain backups (age mode).

Save the schedule

Click Save Schedule. The retention policy will be enforced after the next backup completes.

Global Retention Settings

# View current retention settings
wp safeguard settings get retention

# Set backup limit to 30
wp safeguard settings set retention.limit 30

# Enable delete-by-age mode
wp safeguard settings set retention.deleteByAge true

# Enable auto-delete of local copies after upload
wp safeguard settings set retention.deleteLocalAfterUpload true

Per-Schedule Retention

# List all schedules to find the schedule ID
wp safeguard schedule list

# Update retention for a specific schedule (keep 14 backups)
wp safeguard schedule update <schedule-id> --retention='{"type":"count","value":14}'

# Update retention to keep backups for 90 days
wp safeguard schedule update <schedule-id> --retention='{"type":"days","value":90}'

Global Retention Settings

# Get current retention settings
curl -X GET "https://example.com/wp-json/safeguard/v1/settings/retention" \
  -H "X-WP-Nonce: <nonce>"

# Update retention settings
curl -X POST "https://example.com/wp-json/safeguard/v1/settings/retention" \
  -H "X-WP-Nonce: <nonce>" \
  -H "Content-Type: application/json" \
  -d '{"keepCount": 30, "keepDays": 90, "keepMinimum": 3}'

Per-Schedule Retention

# Update a schedule's retention policy
curl -X PUT "https://example.com/wp-json/safeguard/v1/schedules/<schedule-id>" \
  -H "X-WP-Nonce: <nonce>" \
  -H "Content-Type: application/json" \
  -d '{"retention": {"type": "count", "value": 14}}'

See the REST API reference for full endpoint documentation.

How Retention Works

Understanding when and how SafeGuard enforces retention helps you plan your backup strategy.

When Cleanup Runs

Retention is enforced at two points:

  1. After every scheduled backup completes — SafeGuard checks the schedule's retention policy and deletes any backups that exceed the limit. This is the primary enforcement mechanism.
  2. During daily maintenance — A daily maintenance job cleans up orphaned temporary files, stalled jobs (no activity for over 1 hour), and completed job records older than 30 days.

Manual backups (those not associated with a schedule) are governed by the global retention settings, not per-schedule retention. Make sure your global backup limit is configured if you run manual backups regularly.

Deletion Order

When a count-based retention policy triggers cleanup:

  1. Backups are sorted by creation date, newest first.
  2. The most recent N backups (where N is your retention value) are kept.
  3. Everything beyond that limit is deleted — both the backup file and its database record.

When an age-based retention policy triggers cleanup:

  1. SafeGuard calculates the cutoff date (current time minus N days).
  2. Any backup created before the cutoff is deleted.

Incremental Chain Handling

Incremental backups form chains: a full backup followed by a series of incremental snapshots. SafeGuard manages these chains with built-in safeguards:

  • Maximum chain length — defaults to 10 incremental backups per chain. After reaching this limit, SafeGuard automatically creates a new full backup.
  • Full backup age threshold — defaults to 30 days. If the chain's base full backup is older than this, a new full backup is triggered.
  • Automatic full backup frequency — defaults to every 7 days, ensuring fresh restore points regardless of chain length.

These chain limits mean you always have a recent full backup to restore from, even if older incremental backups are pruned by retention policies.

Per-Schedule Retention

The real power of SafeGuard's retention system is running multiple schedules with different retention policies. This lets you balance protection, storage cost, and restore granularity.

Example: Three-Tier Strategy

ScheduleTypeFrequencyRetentionPurpose
Transaction GuardDatabaseEvery 4 hoursKeep 90Granular database recovery for orders and content
Daily Site BackupIncrementalDaily at 02:00Keep 30Day-level restore points for files and database
Weekly Full BackupFullWeekly at 03:00Keep 8Long-term full restore points spanning 2 months

This gives you 6 database snapshots per day (90 total spanning ~15 days), 30 days of incremental recovery, and 8 weeks of full backup history.

How Per-Schedule Retention Differs from Global

AspectGlobal RetentionPer-Schedule Retention
Applies toManual backupsScheduled backups
Configured inSafeGuard → Settings → RetentionEach schedule's settings
EnforcementBased on total backup count or ageBased on backups created by that specific schedule
ModesCount, age, auto-delete toggleCount or age (per schedule)

Storage Cost Estimation

Use these rough guidelines to estimate how much storage your retention strategy requires. Actual sizes vary based on your site's content, database size, and compression level.

Site SizeFull BackupIncrementalDatabase Only
Small blog (< 500 MB)~200 MB~10-30 MB~5-15 MB
Medium site (1-3 GB)~800 MB~50-150 MB~20-80 MB
Large WooCommerce (5-10 GB)~3 GB~200-500 MB~100-300 MB
Enterprise (20+ GB)~10 GB~500 MB-2 GB~300 MB-1 GB

Estimating Total Storage

Multiply the per-backup size by the number of backups your retention policy keeps:

Total storage = (Full backups x Full size) + (Incremental backups x Incremental size) + (DB backups x DB size)

Example — Medium WooCommerce site with the three-tier strategy above:

  • Weekly full: 8 backups x 800 MB = 6.4 GB
  • Daily incremental: 30 backups x 100 MB = 3 GB
  • 4-hour database: 90 backups x 50 MB = 4.5 GB
  • Total: ~14 GB of cloud storage

Enable Delete local copy after upload if you store backups remotely. This prevents backups from consuming both local disk and cloud storage simultaneously.

Site TypeDB ScheduleFiles ScheduleFull ScheduleEstimated Storage
Personal blogDaily incremental, keep 14Weekly full, keep 41-3 GB
Business siteDaily database, keep 30Daily incremental, keep 14Weekly full, keep 85-15 GB
WooCommerce storeEvery 4h database, keep 90Daily incremental, keep 30Weekly full, keep 810-25 GB
High-traffic WooCommerceEvery 4h database, keep 120Daily incremental, keep 30Weekly full, keep 815-40 GB
Agency (managing clients)Daily database, keep 14Daily incremental, keep 7Weekly full, keep 42-8 GB per site
Membership / LMSEvery 8h database, keep 60Daily incremental, keep 14Weekly full, keep 88-20 GB

SafeGuard's Schedule Recommendations feature can generate an optimized schedule set for your site automatically. Go to SafeGuard → Schedules → Get Recommendations to have SafeGuard analyze your site and suggest the best strategy.

Best Practices

  1. Always keep at least one remote copy — local backups are useless if your server's disk fails. Configure a storage provider and ensure every schedule uploads to it.

  2. Test restores periodically — a backup you cannot restore from is no backup at all. Restore to a staging environment at least once a month to verify integrity.

  3. Monitor storage usage — keep the Storage limit warning setting enabled. SafeGuard will notify you before you run out of space so you can adjust retention or upgrade your storage plan.

  4. Use per-schedule retention, not global — global retention is a safety net for manual backups. For automated schedules, always set retention directly on each schedule for precise control.

  5. Separate database and file schedules — database backups are small and fast, so you can run them frequently with high retention. File backups are larger, so use incremental mode and keep fewer copies.

  6. Delete local copies after upload — if you store backups in S3, Google Drive, or another remote provider, enable Delete local copy after upload to reclaim server disk space.

  7. Keep at least 3 backups minimum — even with aggressive retention, never set your count below 3. This ensures you have fallback restore points if the most recent backup is corrupted.

  8. Review retention quarterly — as your site grows, backup sizes increase. Check your storage usage and adjust retention values to stay within budget.

On this page