I just tossed this code in there to keep only the latest 5 backups:
Code:
// Delete Old Backups
function deleteOLD($directory)
{
$dirs = array($directory);
$files = array();
$files = array_merge($files, scandir($directory, false));
unset($files[0]);
unset($files[1]);
sort($files);
// Loop over all but the 5 newest files and delete them
// Only need the array keys (filenames) since we don't care about timestamps now as the array will be in order
if (count($files) > 5)
{
for ($i = 0; $i < (count($files) - 5); $i++)
{
// You'll probably want to check the return value of this too
$file = $this->DUMP_PATH.$files[$i];
$this->removeFile($file);
echo "<i>[Deleting Old Backup - $file]</i><br />"; vbflush();
}
} else { echo "<i>[No Old Backups to Delete.]</i><br /><br />"; vbflush(); }
}
You can call it whenever you want, I put it after the "Repair and Optimize" section, before the "Start Initial Dump" section.