Chapter 8. Cleanup backups

You can remove old backups to limit the space your backups consume on your local hard drive. It's important to note, that only local backups will be cleaned up. So whatever kind of Sync you are using. Cleanup won't touch your remote files.

If you want to remove your synced backups as well, currently the only way to do this is to use the Rsync sync with it's delete option.

Table 8.1. Supported types of cleanups:

TypeDescription
Capacity Define the size your backups should occupy. If your backups start to exceed this value PHPBU will start to delete backups, starting with the oldest ones.
Outdated Remove backups older than a configured time-value. For example "2W" to delete all backup older than two weeks.
QuantityKeep only a configured amount of backups.


Cleanup by capacity

Remove oldest backups if all created backups exceed the configured limit.

Table 8.2. Capacity-Options

NameValueRequiredDefaultDescription
sizestringyes-Space your backups are allowed to occupy. e.g. 500M for 500 Megabytes or 1G for one Gigabyte.
deleteTargetbooleannofalse If you don't want to keep any backups locally, just specify a size of "0B", set this to "true" and even the current backup will be deleted.


Example 8.1: capacity XML example

<!-- cleanup capacity: keep 250 Megabytes of backups -->
<cleanup type="capacity">
  <option name="size" value="250M"/>
  <option name="deleteTarget" value="false"/>
</cleanup>


Example 8.2: capacity JSON example

{
  "type": "capacity",
  "options": {
    "size": "250M",
    "deleteTarget": "false"
  }
}


Cleanup by date

Remove backups that are older than a configured value.

Table 8.3. Outdated-Options

NameValueRequiredDefaultDescription
olderstringyes-Time to keep backups. e.g. 1m for one month or 20d for twenty days.


Example 8.3: outdated XML example

<!-- cleanup outdated: keep backups for 2 weeks -->
<cleanup type="outdated">
  <option name="older" value="2W"/>
</cleanup>


Example 8.4: outdated JSON example

{
  "type": "Outdated",
  "options": {
    "older": "2W"
  }
}


Cleanup by quantity

Keep only a configured amount of backups.

Table 8.4. Quantity-Options

NameValueRequiredDefaultDescription
amountstringyes-The amount of backups to keep.


Example 8.5: quantity XML example

<!-- cleanup quantity: keep the last 20 backups -->
<cleanup type="quantity">
  <option name="amount" value="20"/>
</cleanup>


Example 8.6: quantity JSON example

{
  "type": "quantity",
  "options": {
    "amount": "20"
  }
}


Please open a ticket on GitHub to suggest improvements to this page. Thanks!