/**
  * Update database when 'mysqlBckComplete' event recieved from instance
  *
  * @param MysqlBackupCompleteEvent $event
  */
 public function OnMysqlBackupComplete(MysqlBackupCompleteEvent $event)
 {
     try {
         $DBFarmRole = $event->DBServer->GetFarmRoleObject();
         $farm_roleid = $DBfarmRole->ID;
     } catch (Exception $e) {
         return;
     }
     if ($event->Operation == MYSQL_BACKUP_TYPE::DUMP) {
         $DBFarmRole->SetSetting(DBFarmRole::SETTING_MYSQL_LAST_BCP_TS, time());
         $DBFarmRole->SetSetting(DBFarmRole::SETTING_MYSQL_IS_BCP_RUNNING, 0);
     } elseif ($event->Operation == MYSQL_BACKUP_TYPE::BUNDLE) {
         $DBFarmRole->SetSetting(DBFarmRole::SETTING_MYSQL_LAST_BUNDLE_TS, time());
         $DBFarmRole->SetSetting(DBFarmRole::SETTING_MYSQL_IS_BUNDLE_RUNNING, 0);
         if (!is_array($event->SnapshotInfo)) {
             $event->SnapshotInfo = array('snapshotId' => $event->SnapshotInfo);
         }
         if ($event->SnapshotInfo['snapshotId']) {
             if ($DBFarmRole->GetSetting(DBFarmRole::SETTING_MYSQL_DATA_STORAGE_ENGINE) == MYSQL_STORAGE_ENGINE::EBS) {
                 $this->DB->Execute("INSERT INTO ebs_snaps_info SET snapid=?, comment=?, dtcreated=NOW(), region=?, ebs_array_snapid='0', is_autoebs_master_snap='1', farm_roleid=?", array($event->SnapshotInfo['snapshotId'], _('MySQL Master volume snapshot'), $event->DBServer->GetProperty(EC2_SERVER_PROPERTIES::REGION), $DBFarmRole->ID));
                 // Scalarizr stuff
                 $DBFarmRole->SetSetting(DBFarmRole::SETTING_MYSQL_SNAPSHOT_ID, $event->SnapshotInfo['snapshotId']);
                 $snapshotConfig = new stdClass();
                 $snapshotConfig->type = 'ebs';
                 $snapshotConfig->id = $event->SnapshotInfo['snapshotId'];
                 $event->SnapshotInfo['snapshotConfig'] = $snapshotConfig;
             }
         }
         if ($event->SnapshotInfo['logFile']) {
             $DBFarmRole->SetSetting(DBFarmRole::SETTING_MYSQL_LOG_FILE, $event->SnapshotInfo['logFile']);
         }
         if ($event->SnapshotInfo['logPos']) {
             $DBFarmRole->SetSetting(DBFarmRole::SETTING_MYSQL_LOG_POS, $event->SnapshotInfo['logPos']);
         }
         try {
             $storageSnapshot = Scalr_Storage_Snapshot::init();
             $storageSnapshot->loadBy(array('id' => $event->SnapshotInfo['snapshotConfig']->id, 'client_id' => $event->DBServer->clientId, 'farm_id' => $event->DBServer->farmId, 'farm_roleid' => $event->DBServer->farmRoleId, 'env_id' => $event->DBServer->envId, 'name' => sprintf(_("MySQL data bundle #%s"), $event->SnapshotInfo['snapshotConfig']->id), 'type' => $DBFarmRole->GetSetting(DBFarmRole::SETTING_MYSQL_DATA_STORAGE_ENGINE), 'platform' => $event->DBServer->platform, 'description' => sprintf(_("MySQL data bundle created on Farm '%s' -> Role '%s'"), $DBFarmRole->GetFarmObject()->Name, $DBFarmRole->GetRoleObject()->name), 'ismysql' => true, 'service' => ROLE_BEHAVIORS::MYSQL));
             $storageSnapshot->setConfig($event->SnapshotInfo['snapshotConfig']);
             $storageSnapshot->save(true);
             $DBFarmRole->SetSetting(DBFarmRole::SETTING_MYSQL_SCALR_SNAPSHOT_ID, $storageSnapshot->id);
         } catch (Exception $e) {
             $this->Logger->fatal("Cannot save storage snapshot: {$e->getMessage()}");
         }
     }
 }
 public function OnHostInit(HostInitEvent $event)
 {
     $msg = new Scalr_Messaging_Msg_HostInitResponse($event->DBServer->GetFarmObject()->GetSetting(DBFarm::SETTING_CRYPTO_KEY), $event->DBServer->index);
     $msg->cloudLocation = $event->DBServer->GetCloudLocation();
     $dbServer = $event->DBServer;
     $dbFarmRole = $dbServer->GetFarmRoleObject();
     if ($dbFarmRole) {
         foreach (Scalr_Role_Behavior::getListForFarmRole($dbFarmRole) as $behavior) {
             $msg = $behavior->extendMessage($msg, $dbServer);
         }
     }
     $msg->setGlobalVariables($dbServer, true, $event);
     /**
      * TODO: Move everything to Scalr_Db_Msr_*
      */
     if ($dbFarmRole->GetRoleObject()->hasBehavior(ROLE_BEHAVIORS::MYSQL)) {
         $isMaster = (int) $dbServer->GetProperty(SERVER_PROPERTIES::DB_MYSQL_MASTER);
         $msg->mysql = (object) array("replicationMaster" => $isMaster, "rootPassword" => $dbFarmRole->GetSetting(DBFarmRole::SETTING_MYSQL_ROOT_PASSWORD), "replPassword" => $dbFarmRole->GetSetting(DBFarmRole::SETTING_MYSQL_REPL_PASSWORD), "statPassword" => $dbFarmRole->GetSetting(DBFarmRole::SETTING_MYSQL_STAT_PASSWORD), "logFile" => $dbFarmRole->GetSetting(DBFarmRole::SETTING_MYSQL_LOG_FILE), "logPos" => $dbFarmRole->GetSetting(DBFarmRole::SETTING_MYSQL_LOG_POS));
         if ($event->DBServer->IsSupported("0.7")) {
             if ($dbFarmRole->GetSetting(DBFarmRole::SETTING_MYSQL_SCALR_VOLUME_ID) && $isMaster) {
                 try {
                     $volume = Scalr_Storage_Volume::init()->loadById($dbFarmRole->GetSetting(DBFarmRole::SETTING_MYSQL_SCALR_VOLUME_ID));
                     $msg->mysql->volumeConfig = $volume->getConfig();
                 } catch (Exception $e) {
                 }
             }
             /***
              * For Rackspace we ALWAYS need snapsjot_config for mysql
              * ***/
             if ($dbFarmRole->GetSetting(DBFarmRole::SETTING_MYSQL_SCALR_SNAPSHOT_ID)) {
                 try {
                     $snapshotConfig = Scalr_Storage_Snapshot::init()->loadById($dbFarmRole->GetSetting(DBFarmRole::SETTING_MYSQL_SCALR_SNAPSHOT_ID));
                     $msg->mysql->snapshotConfig = $snapshotConfig->getConfig();
                 } catch (Exception $e) {
                     $this->Logger->error(new FarmLogMessage($event->DBServer->farmId, "Cannot get snaphotConfig for hostInit message: {$e->getMessage()}"));
                 }
             }
             if (!$msg->mysql->snapshotConfig && $dbFarmRole->GetSetting(DBFarmRole::SETTING_MYSQL_SNAPSHOT_ID)) {
                 $msg->mysql->snapshotConfig = new stdClass();
                 $msg->mysql->snapshotConfig->type = $dbFarmRole->GetSetting(DBFarmRole::SETTING_MYSQL_DATA_STORAGE_ENGINE);
                 $msg->mysql->snapshotConfig->id = $dbFarmRole->GetSetting(DBFarmRole::SETTING_MYSQL_SNAPSHOT_ID);
             }
             if ($isMaster && !$msg->mysql->volumeConfig) {
                 $msg->mysql->volumeConfig = new stdClass();
                 $msg->mysql->volumeConfig->type = $dbFarmRole->GetSetting(DBFarmRole::SETTING_MYSQL_DATA_STORAGE_ENGINE);
                 if (!$dbFarmRole->GetSetting(DBFarmRole::SETTING_MYSQL_MASTER_EBS_VOLUME_ID)) {
                     if (in_array($dbFarmRole->GetSetting(DBFarmRole::SETTING_MYSQL_DATA_STORAGE_ENGINE), array(MYSQL_STORAGE_ENGINE::EBS, MYSQL_STORAGE_ENGINE::CSVOL))) {
                         $msg->mysql->volumeConfig->size = $dbFarmRole->GetSetting(DBFarmRole::SETTING_MYSQL_EBS_VOLUME_SIZE);
                         if ($dbFarmRole->GetSetting(DBFarmRole::SETTING_MYSQL_DATA_STORAGE_ENGINE) == MYSQL_STORAGE_ENGINE::EBS) {
                             $msg->mysql->volumeConfig->volumeType = $dbFarmRole->GetSetting(DBFarmRole::SETTING_MYSQL_EBS_TYPE);
                             if ($msg->mysql->volumeConfig->volumeType == 'io1') {
                                 $msg->mysql->volumeConfig->iops = $dbFarmRole->GetSetting(DBFarmRole::SETTING_MYSQL_EBS_IOPS);
                             }
                         }
                     } elseif ($dbFarmRole->GetSetting(DBFarmRole::SETTING_MYSQL_DATA_STORAGE_ENGINE) == MYSQL_STORAGE_ENGINE::EPH) {
                         //$msg->mysql->volumeConfig->snap_backend = "cf://mysql-data-bundle/scalr-{$dbFarmRole->GetFarmObject()->Hash}";
                         $msg->mysql->volumeConfig->snap_backend = sprintf("cf://scalr-%s-%s/data-bundles/%s/mysql/", $event->DBServer->envId, $event->DBServer->GetCloudLocation(), $event->DBServer->farmId);
                         $msg->mysql->volumeConfig->vg = 'mysql';
                         $msg->mysql->volumeConfig->disk = new stdClass();
                         $msg->mysql->volumeConfig->disk->type = 'loop';
                         $msg->mysql->volumeConfig->disk->size = '75%root';
                     }
                 } else {
                     $msg->mysql->volumeConfig->id = $dbFarmRole->GetSetting(DBFarmRole::SETTING_MYSQL_MASTER_EBS_VOLUME_ID);
                 }
             }
         } else {
             if ($isMaster) {
                 $msg->mysql->volumeId = $dbFarmRole->GetSetting(DBFarmRole::SETTING_MYSQL_MASTER_EBS_VOLUME_ID);
             }
             $msg->mysql->snapshotId = $dbFarmRole->GetSetting(DBFarmRole::SETTING_MYSQL_SNAPSHOT_ID);
         }
     }
     // Create ssh keypair for rackspace
     if ($event->DBServer->IsSupported("0.7")) {
         $authSshKey = $event->DBServer->platform == SERVER_PLATFORMS::RACKSPACE || $event->DBServer->platform == SERVER_PLATFORMS::NIMBULA || $event->DBServer->isCloudstack();
         if ($event->DBServer->isOpenstack()) {
             $platform = PlatformFactory::NewPlatform($event->DBServer->platform);
             $isKeyPairsSupported = $platform->getConfigVariable(OpenstackPlatformModule::EXT_KEYPAIRS_ENABLED, $event->DBServer->GetEnvironmentObject(), false);
             if ($isKeyPairsSupported != 1) {
                 $authSshKey = true;
             }
         }
         if ($authSshKey) {
             $sshKey = Scalr_SshKey::init();
             if (!$sshKey->loadGlobalByFarmId($event->DBServer->envId, $event->DBServer->farmId, $event->DBServer->GetFarmRoleObject()->CloudLocation, $event->DBServer->platform)) {
                 $key_name = "FARM-{$event->DBServer->farmId}-" . SCALR_ID;
                 $sshKey->generateKeypair();
                 $sshKey->farmId = $event->DBServer->farmId;
                 $sshKey->envId = $event->DBServer->envId;
                 $sshKey->type = Scalr_SshKey::TYPE_GLOBAL;
                 $sshKey->platform = $event->DBServer->platform;
                 $sshKey->cloudLocation = $event->DBServer->GetFarmRoleObject()->CloudLocation;
                 $sshKey->cloudKeyName = $key_name;
                 $sshKey->platform = $event->DBServer->platform;
                 $sshKey->save();
             }
             $sshKeysMsg = new Scalr_Messaging_Msg_UpdateSshAuthorizedKeys(array($sshKey->getPublic()), array());
             $event->DBServer->SendMessage($sshKeysMsg, false, true);
         }
     }
     // Send HostInitResponse to target server
     $event->DBServer->SendMessage($msg);
     // Send broadcast HostInit
     $servers = DBFarm::LoadByID($this->FarmID)->GetServersByFilter(array('status' => array(SERVER_STATUS::INIT, SERVER_STATUS::RUNNING)));
     $event->msgExpected = count($servers);
     foreach ((array) $servers as $DBServer) {
         if (!$DBServer->IsSupported('0.5')) {
             $event->msgExpected--;
             continue;
         }
         if ($DBServer->status == SERVER_STATUS::INIT && $DBServer->serverId != $event->DBServer->serverId) {
             $event->msgExpected--;
             continue;
         }
         $hiMsg = new Scalr_Messaging_Msg_HostInit();
         $hiMsg->setServerMetaData($event->DBServer);
         $hiMsg = Scalr_Scripting_Manager::extendMessage($hiMsg, $event, $event->DBServer, $DBServer);
         if ($event->DBServer->farmRoleId != 0) {
             foreach (Scalr_Role_Behavior::getListForFarmRole($event->DBServer->GetFarmRoleObject()) as $behavior) {
                 $hiMsg = $behavior->extendMessage($hiMsg, $event->DBServer);
             }
         }
         $hiMsg = $DBServer->SendMessage($hiMsg, false, true);
         if ($hiMsg->dbMessageId) {
             $event->msgCreated++;
         }
     }
 }
Beispiel #3
0
 public function getSnapshotConfig(DBFarmRole $dbFarmRole, DBServer $dbServer)
 {
     $snapshotId = $this->getSnapshotIdByServer($dbServer);
     if ($snapshotId) {
         try {
             $snapshot = Scalr_Storage_Snapshot::init()->loadById($snapshotId);
             return $snapshot->getConfig();
         } catch (Exception $e) {
         }
     }
     return null;
 }
 /**
  * @param Scalr_Messaging_Msg $message
  * @param DBServer $dbserver
  */
 private function onHostUp($message, $dbserver, $skipStatusCheck = false)
 {
     if ($dbserver->status == SERVER_STATUS::INIT || $skipStatusCheck) {
         $event = new HostUpEvent($dbserver, "");
         $dbFarmRole = $dbserver->GetFarmRoleObject();
         foreach (Scalr_Role_Behavior::getListForFarmRole($dbFarmRole) as $behavior) {
             $behavior->handleMessage($message, $dbserver);
         }
         //TODO: Move MySQL to MSR
         /****** MOVE TO MSR ******/
         //TODO: Legacy MySQL code
         if ($dbFarmRole->GetRoleObject()->hasBehavior(ROLE_BEHAVIORS::MYSQL)) {
             if (!$message->mysql) {
                 $this->logger->error(sprintf("Strange situation. HostUp message from MySQL behavior doesn't contains `mysql` property. Server %s (%s)", $dbserver->serverId, $dbserver->remoteIp));
                 return;
             }
             $mysqlData = $message->mysql;
             if ($dbserver->GetProperty(SERVER_PROPERTIES::DB_MYSQL_MASTER)) {
                 if ($mysqlData->rootPassword) {
                     $dbFarmRole->SetSetting(DBFarmRole::SETTING_MYSQL_REPL_PASSWORD, $mysqlData->replPassword);
                     $dbFarmRole->SetSetting(DBFarmRole::SETTING_MYSQL_ROOT_PASSWORD, $mysqlData->rootPassword);
                     $dbFarmRole->SetSetting(DBFarmRole::SETTING_MYSQL_STAT_PASSWORD, $mysqlData->statPassword);
                 }
                 $dbFarmRole->SetSetting(DBFarmRole::SETTING_MYSQL_LOG_FILE, $mysqlData->logFile);
                 $dbFarmRole->SetSetting(DBFarmRole::SETTING_MYSQL_LOG_POS, $mysqlData->logPos);
                 if ($dbserver->IsSupported("0.7")) {
                     //$dbFarmRole->SetSetting(DBFarmRole::SETTING_MYSQL_SNAPSHOT_ID, $mysqlData->snapshotConfig);
                     //$dbFarmRole->SetSetting(DBFarmRole::SETTING_MYSQL_SNAPSHOT_ID, $mysqlData->volumeConfig);
                     if ($mysqlData->volumeConfig) {
                         try {
                             $storageVolume = Scalr_Storage_Volume::init();
                             try {
                                 $storageVolume->loadById($mysqlData->volumeConfig->id);
                                 $storageVolume->setConfig($mysqlData->volumeConfig);
                                 $storageVolume->save();
                             } catch (Exception $e) {
                                 if (strpos($e->getMessage(), 'not found')) {
                                     $storageVolume->loadBy(array('id' => $mysqlData->volumeConfig->id, 'client_id' => $dbserver->clientId, 'env_id' => $dbserver->envId, 'name' => "MySQL data volume", 'type' => $dbFarmRole->GetSetting(DBFarmRole::SETTING_MYSQL_DATA_STORAGE_ENGINE), 'platform' => $dbserver->platform, 'size' => $mysqlData->volumeConfig->size, 'fstype' => $mysqlData->volumeConfig->fstype, 'purpose' => ROLE_BEHAVIORS::MYSQL, 'farm_roleid' => $dbserver->farmRoleId, 'server_index' => $dbserver->index));
                                     $storageVolume->setConfig($mysqlData->volumeConfig);
                                     $storageVolume->save(true);
                                 } else {
                                     throw $e;
                                 }
                             }
                             $dbFarmRole->SetSetting(DBFarmRole::SETTING_MYSQL_SCALR_VOLUME_ID, $storageVolume->id);
                         } catch (Exception $e) {
                             $this->logger->error(new FarmLogMessage($event->DBServer->farmId, "Cannot save storage volume: {$e->getMessage()}"));
                         }
                     }
                     if ($mysqlData->snapshotConfig) {
                         try {
                             $storageSnapshot = Scalr_Storage_Snapshot::init();
                             try {
                                 $storageSnapshot->loadById($mysqlData->snapshotConfig->id);
                                 $storageSnapshot->setConfig($mysqlData->snapshotConfig);
                                 $storageSnapshot->save();
                             } catch (Exception $e) {
                                 if (strpos($e->getMessage(), 'not found')) {
                                     $storageSnapshot->loadBy(array('id' => $mysqlData->snapshotConfig->id, 'client_id' => $dbserver->clientId, 'farm_id' => $dbserver->farmId, 'farm_roleid' => $dbserver->farmRoleId, 'env_id' => $dbserver->envId, 'name' => sprintf(_("MySQL data bundle #%s"), $mysqlData->snapshotConfig->id), 'type' => $dbFarmRole->GetSetting(DBFarmRole::SETTING_MYSQL_DATA_STORAGE_ENGINE), 'platform' => $dbserver->platform, 'description' => sprintf(_("MySQL data bundle created on Farm '%s' -> Role '%s'"), $dbFarmRole->GetFarmObject()->Name, $dbFarmRole->GetRoleObject()->name), 'ismysql' => true, 'service' => ROLE_BEHAVIORS::MYSQL));
                                     $storageSnapshot->setConfig($mysqlData->snapshotConfig);
                                     $storageSnapshot->save(true);
                                 } else {
                                     throw $e;
                                 }
                             }
                             $dbFarmRole->SetSetting(DBFarmRole::SETTING_MYSQL_SCALR_SNAPSHOT_ID, $storageSnapshot->id);
                         } catch (Exception $e) {
                             $this->logger->error(new FarmLogMessage($event->DBServer->farmId, "Cannot save storage snapshot: {$e->getMessage()}"));
                         }
                     }
                 } else {
                     /**
                      * @deprecated
                      */
                     $dbFarmRole->SetSetting(DBFarmRole::SETTING_MYSQL_SNAPSHOT_ID, $mysqlData->snapshotId);
                 }
             }
         }
         return $event;
     } else {
         $this->logger->error("Strange situation. Received HostUp message" . " from server '{$dbserver->serverId}' ('{$message->remoteIp})" . " with state {$dbserver->status}!");
     }
 }
Beispiel #5
0
 public function getSnapshotConfig(DBFarmRole $dbFarmRole, DBServer $dbServer)
 {
     $r = new ReflectionClass($this);
     if ($r->hasConstant("ROLE_SNAPSHOT_ID")) {
         if ($dbFarmRole->GetSetting(static::ROLE_SNAPSHOT_ID)) {
             try {
                 $snapshot = Scalr_Storage_Snapshot::init()->loadById($dbFarmRole->GetSetting(static::ROLE_SNAPSHOT_ID));
                 return $snapshot->getConfig();
             } catch (Exception $e) {
             }
         }
     }
     return false;
 }
Beispiel #6
0
 public static function onCreateDataBundleResult(Scalr_Messaging_Msg $message, DBServer $dbServer)
 {
     $dbFarm = $dbServer->GetFarmObject();
     $dbFarmRole = $dbServer->GetFarmRoleObject();
     $dbFarmRole->SetSetting(Scalr_Db_Msr::DATA_BUNDLE_LAST_TS, time(), DBFarmRole::TYPE_LCL);
     $dbFarmRole->SetSetting(Scalr_Db_Msr::DATA_BUNDLE_IS_RUNNING, 0, DBFarmRole::TYPE_LCL);
     //$dbFarmRole->SetSetting(Scalr_Db_Msr::DATA_BUNDLE_SERVER_ID, "");
     $dbSettings = $message->{$message->dbType};
     if ($dbSettings->snapshotConfig) {
         try {
             try {
                 $snapshot = Scalr_Storage_Snapshot::init();
                 $snapshot->loadBy(array('id' => $dbSettings->snapshotConfig->id, 'client_id' => $dbServer->clientId, 'env_id' => $dbServer->envId, 'farm_id' => $dbServer->farmId, 'farm_roleid' => $dbServer->farmRoleId, 'name' => "Automatical '{$message->dbType}' data bundle", 'type' => $dbFarmRole->GetSetting(Scalr_Db_Msr::DATA_STORAGE_ENGINE), 'platform' => $dbServer->platform, 'description' => "'{$message->dbType}' data bundle created automatically by Scalr", 'service' => $message->dbType));
                 $snapshot->setConfig($dbSettings->snapshotConfig);
                 $snapshot->save(true);
             } catch (Exception $e) {
                 if (!stristr($e->getMessage(), "Duplicate entry")) {
                     throw $e;
                 }
             }
             $dbFarmRole->SetSetting(Scalr_Db_Msr::SNAPSHOT_ID, $snapshot->id);
             if ($message->dbType == self::DB_TYPE_MYSQL) {
                 $dbFarmRole->SetSetting(Scalr_Db_Msr_Mysql::LOG_FILE, $dbSettings->logFile, DBFarmRole::TYPE_LCL);
                 $dbFarmRole->SetSetting(Scalr_Db_Msr_Mysql::LOG_POS, $dbSettings->logPos, DBFarmRole::TYPE_LCL);
             } elseif ($message->dbType == self::DB_TYPE_MYSQL2 || $message->dbType == self::DB_TYPE_PERCONA || $message->dbType == self::DB_TYPE_MARIADB) {
                 $dbFarmRole->SetSetting(Scalr_Db_Msr_Mysql2::LOG_FILE, $dbSettings->logFile, DBFarmRole::TYPE_LCL);
                 $dbFarmRole->SetSetting(Scalr_Db_Msr_Mysql2::LOG_POS, $dbSettings->logPos, DBFarmRole::TYPE_LCL);
             } elseif ($message->dbType == self::DB_TYPE_POSTGRESQL) {
                 $dbFarmRole->SetSetting(Scalr_Db_Msr_Postgresql::XLOG_LOCATION, $dbSettings->currentXlogLocation, DBFarmRole::TYPE_LCL);
             } elseif ($message->dbType == self::DB_TYPE_REDIS) {
                 //Nothing todo
             }
         } catch (Exception $e) {
             Logger::getLogger(__CLASS__)->error(new FarmLogMessage($dbServer->farmId, "Cannot save storage snapshot: {$e->getMessage()}"));
         }
     }
 }
Beispiel #7
0
 /**
  * Update database when 'mysqlBckComplete' event recieved from instance
  *
  * @param MysqlBackupCompleteEvent $event
  */
 public function OnMysqlBackupComplete(MysqlBackupCompleteEvent $event)
 {
     try {
         $DBFarmRole = $event->DBServer->GetFarmRoleObject();
         $farm_roleid = $DBfarmRole->ID;
     } catch (Exception $e) {
         return;
     }
     if ($event->Operation == MYSQL_BACKUP_TYPE::DUMP) {
         $DBFarmRole->SetSetting(DBFarmRole::SETTING_MYSQL_LAST_BCP_TS, time(), DBFarmRole::TYPE_LCL);
         $DBFarmRole->SetSetting(DBFarmRole::SETTING_MYSQL_IS_BCP_RUNNING, 0, DBFarmRole::TYPE_LCL);
         switch ($event->DBServer->platform) {
             case SERVER_PLATFORMS::EC2:
                 $provider = 's3';
                 break;
             case SERVER_PLATFORMS::RACKSPACE:
                 $provider = 'cf';
                 break;
             default:
                 $provider = 'unknown';
                 break;
         }
         $backup = Scalr_Db_Backup::init();
         $backup->service = 'mysql';
         $backup->platform = $event->DBServer->platform;
         $backup->provider = $provider;
         $backup->envId = $event->DBServer->envId;
         $backup->farmId = $event->DBServer->farmId;
         $backup->cloudLocation = $event->DBServer->GetCloudLocation();
         $backup->status = Scalr_Db_Backup::STATUS_AVAILABLE;
         $total = 0;
         foreach ($event->backupParts as $item) {
             if (is_object($item) && $item->size) {
                 $backup->addPart(str_replace(array("s3://", "cf://"), array("", ""), $item->path), $item->size);
                 $total = $total + (int) $item->size;
             } else {
                 $backup->addPart(str_replace(array("s3://", "cf://"), array("", ""), $item), 0);
             }
         }
         $backup->size = $total;
         $backup->save();
     } elseif ($event->Operation == MYSQL_BACKUP_TYPE::BUNDLE) {
         $DBFarmRole->SetSetting(DBFarmRole::SETTING_MYSQL_LAST_BUNDLE_TS, time(), DBFarmRole::TYPE_LCL);
         $DBFarmRole->SetSetting(DBFarmRole::SETTING_MYSQL_IS_BUNDLE_RUNNING, 0, DBFarmRole::TYPE_LCL);
         if (!is_array($event->SnapshotInfo)) {
             $event->SnapshotInfo = array('snapshotId' => $event->SnapshotInfo);
         }
         if ($event->SnapshotInfo['snapshotId']) {
             if ($DBFarmRole->GetSetting(DBFarmRole::SETTING_MYSQL_DATA_STORAGE_ENGINE) == MYSQL_STORAGE_ENGINE::EBS) {
                 $this->DB->Execute("INSERT INTO ebs_snaps_info SET snapid=?, comment=?, dtcreated=NOW(), region=?, ebs_array_snapid='0', is_autoebs_master_snap='1', farm_roleid=?", array($event->SnapshotInfo['snapshotId'], _('MySQL Master volume snapshot'), $event->DBServer->GetProperty(EC2_SERVER_PROPERTIES::REGION), $DBFarmRole->ID));
                 // Scalarizr stuff
                 $DBFarmRole->SetSetting(DBFarmRole::SETTING_MYSQL_SNAPSHOT_ID, $event->SnapshotInfo['snapshotId'], DBFarmRole::TYPE_LCL);
                 $snapshotConfig = new stdClass();
                 $snapshotConfig->type = 'ebs';
                 $snapshotConfig->id = $event->SnapshotInfo['snapshotId'];
                 $event->SnapshotInfo['snapshotConfig'] = $snapshotConfig;
             }
         }
         if ($event->SnapshotInfo['logFile']) {
             $DBFarmRole->SetSetting(DBFarmRole::SETTING_MYSQL_LOG_FILE, $event->SnapshotInfo['logFile'], DBFarmRole::TYPE_LCL);
         }
         if ($event->SnapshotInfo['logPos']) {
             $DBFarmRole->SetSetting(DBFarmRole::SETTING_MYSQL_LOG_POS, $event->SnapshotInfo['logPos'], DBFarmRole::TYPE_LCL);
         }
         try {
             $storageSnapshot = Scalr_Storage_Snapshot::init();
             $storageSnapshot->loadBy(array('id' => $event->SnapshotInfo['snapshotConfig']->id, 'client_id' => $event->DBServer->clientId, 'farm_id' => $event->DBServer->farmId, 'farm_roleid' => $event->DBServer->farmRoleId, 'env_id' => $event->DBServer->envId, 'name' => sprintf(_("MySQL data bundle #%s"), $event->SnapshotInfo['snapshotConfig']->id), 'type' => $DBFarmRole->GetSetting(DBFarmRole::SETTING_MYSQL_DATA_STORAGE_ENGINE), 'platform' => $event->DBServer->platform, 'description' => sprintf(_("MySQL data bundle created on Farm '%s' -> Role '%s'"), $DBFarmRole->GetFarmObject()->Name, $DBFarmRole->GetRoleObject()->name), 'ismysql' => true, 'service' => ROLE_BEHAVIORS::MYSQL));
             $storageSnapshot->setConfig($event->SnapshotInfo['snapshotConfig']);
             $storageSnapshot->save(true);
             $DBFarmRole->SetSetting(DBFarmRole::SETTING_MYSQL_SCALR_SNAPSHOT_ID, $storageSnapshot->id, DBFarmRole::TYPE_LCL);
         } catch (Exception $e) {
             $this->Logger->fatal("Cannot save storage snapshot: {$e->getMessage()}");
         }
     }
 }