You are here

public function Gardener::prune in Backup and migrate prune 7.2

Same name and namespace in other branches
  1. 7 class/Gardener.php \Gardener::prune()

Delete the files that match the criteria

Return value

int The number of deleted backups

Throws

ErrorException

File

class/Gardener.php, line 141
Gardener class implementation file

Class

Gardener
Gardener class implementation

Code

public function prune() {
  $destination = $this
    ->getDestination();
  if (!$destination
    ->op('delete')) {
    throw new ErrorException('This destination cannot be prunned because deleting is not supported.', WATCHDOG_ERROR);
  }
  $files = $this
    ->arrangeFiles();
  $deleted = 0;
  foreach ($files as $slot => $fileset) {

    // Foreach outer_category we need to prune and select a month
    foreach ($fileset as $outer_category => $inner_fileset) {
      $deleted += $this
        ->processPrune($inner_fileset, $slot);
    }
  }
  return $deleted;
}