Chapter 9. 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 9.1. Supported types of cleanups:

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 9.2. Capacity-Options

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 9.1: capacity XML example

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

Example 9.2: capacity JSON example

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

Cleanup by date

Remove backups that are older than a configured value.

Table 9.3. Outdated-Options

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

Example 9.3: outdated XML example

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

Example 9.4: outdated JSON example

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

Cleanup by quantity

Keep only a configured amount of backups.

Table 9.4. Quantity-Options

amountstringyes-The amount of backups to keep.

Example 9.5: quantity XML example

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

Example 9.6: quantity JSON example

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

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