private function rotateBackup($regexp, $numberBackups = null, $service = 'adodb')
{
$db = \Scalr::getContainer()->{$service};
//Persists only recent seven backups by default
$numberBackups = $numberBackups ?: 7;
$tables = $db->GetCol("\n SELECT `TABLE_NAME`\n FROM `INFORMATION_SCHEMA`.`TABLES`\n WHERE `TABLE_SCHEMA` = DATABASE()\n AND `TABLE_NAME` REGEXP '" . $regexp . "'\n ORDER BY `CREATE_TIME`\n ");
if (!empty($tables) && ($cnt = count($tables)) > $numberBackups) {
for ($i = 0; $i + $numberBackups < $cnt; ++$i) {
$this->getLogger()->info("Removing %s from archive", $tables[$i]);
$db->Execute("DROP TABLE `" . $tables[$i] . "`");
}
}
}