Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fballiano/5c8fd381da79d14ddcf1 to your computer and use it in GitHub Desktop.
Save fballiano/5c8fd381da79d14ddcf1 to your computer and use it in GitHub Desktop.
<?php
require_once 'abstract.php';
class Shell_Delete_Old_Enterprise_Staging_Backups extends Mage_Shell_Abstract
{
public function run()
{
$actions = Mage::getModel("enterprise_staging/staging_action")->getCollection()
->addFieldToFilter("type", "backup")
->addFieldToFilter("status", "completed")
->addFieldToFilter("updated_at", array("lt"=>date("Y-m-d H:i:s", strtotime("-7days"))))
->setOrder("updated_at", "ASC");
foreach ($actions as $action) {
echo "Removed staging backup {$action->getId()} {$action->getUpdatedAt()} {$action->getStagingTablePrefix()}\n";
$action->setIsDeleteTables(true);
$action->delete();
}
}
}
$shell = new Shell_Delete_Old_Enterprise_Staging_Backups();
$shell->run();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment