function _finalise() { global $mainframe; $this->_enforce_minexectime(true); // The backup is over. Did we encounter any errors? if ($this->getError()) { JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, "CUBE - Can't finalise due to errors"); // Notify Super Administrators if it's a front-end backup if (!$mainframe->isAdmin()) { $this->_mailToSuperAdministrators($this->getError()); } // Oops! Have to reset() because of the error $this->reset(); } else { JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, "CUBE - Finalising backup started"); // Notify Super Administrators if it's a front-end backup if (!$mainframe->isAdmin()) { $this->_mailToSuperAdministrators(); } // Remove temp files JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, "Removing temporary files"); JoomlapackCUBETempfiles::deleteTempFiles(); JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, "Updating statistics"); // We finished normally. Fetch the stats record $this->statmodel = null; $this->statmodel = new JoomlapackModelStatistics($this->_statID); $this->statmodel->setId($this->_statID); $statRecord =& $this->statmodel->getStatistic(); jimport('joomla.utilities.date'); $jdate = new JDate(); $statRecord->backupend = $jdate->toMySQL(); $statRecord->status = 'complete'; $this->statmodel->save($statRecord); // Apply quotas $errorReporting = @error_reporting(0); $quotaFiles = $this->statmodel->getOldBackupsToDelete(); if (count($quotaFiles) > 0) { JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, "Applying quotas"); jimport('joomla.filesystem.file'); foreach ($quotaFiles as $file) { if (!@unlink($file)) { // FIX 2.0: Using JFile::delete raised warnings which messed up XMLRPC output. After all, we write backup files from PHP, using FTP should not be necessary to delete them! $this->addWarning("Failed to remove old backup file " . $file); } } } @error_reporting($errorReporting); // Set internal variables and go to bed... er... I mean, return control to the user $this->_isFinished = true; $this->_activeDomain = 'finale'; JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, "CUBE - Finalising backup ended"); } $this->_enforce_minexectime(false); }
/** * Find where to store the backup files */ function _getBackupFilePaths() { $configuration =& JoomlapackModelRegistry::getInstance(); switch ($configuration->get('BackupType')) { case 'dbonly': // On DB Only backups we use different naming, no matter what's the setting JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, "JoomlapackDumperDefault :: Only dump database mode detected"); // Fix 2.0: Backup file name MUST be taken from the statitics record! $cube =& JoomlapackCUBE::getInstance(); $statID = $cube->_statID; $statModel = new JoomlapackModelStatistics($statID); $statModel->setId($statID); $statRecord =& $statModel->getStatistic(); $this->_tempFile = $statRecord->absolute_path; $this->_saveAsName = ''; break; case 'full': if ($this->_dumpFile != '') { JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, "JoomlapackDumperDefault :: Forced filename using dumpFile found."); // If the dumpFile was set, forcibly use this value $this->_tempFile = JoomlapackCUBETempfiles::registerTempFile(dechex(crc32(microtime() . $this->_dumpFile))); $this->_saveAsName = 'installation/sql/' . $this->_dumpFile; } else { if ($this->_isJoomla) { // Joomla! Core Database, use the JoomlaPack way of figuring out the filenames JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, "JoomlapackDumperDefault :: Core database"); $this->_tempFile = JoomlapackCUBETempfiles::registerTempFile(dechex(crc32(microtime() . 'joomla.sql'))); $this->_saveAsName = 'installation/sql/joomla.sql'; } else { // External databases, we use the database's name JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, "JoomlapackDumperDefault :: External database"); $this->_tempFile = JoomlapackCUBETempfiles::registerTempFile(dechex(crc32(microtime() . $this->_database . '.sql'))); $this->_saveAsName = 'installation/sql/' . $this->_database . '.sql'; } } break; case 'extradbonly': if ($this->_dumpFile != '') { JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, "JoomlapackDumperDefault :: Forced filename using dumpFile found."); // If the dumpFile was set, forcibly use this value $this->_tempFile = JoomlapackCUBETempfiles::registerTempFile(dechex(crc32(microtime() . $this->_dumpFile))); $this->_saveAsName = $this->_dumpFile; } else { if ($this->_isJoomla) { // Joomla! Core Database, use the JoomlaPack way of figuring out the filenames JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, "JoomlapackDumperDefault :: Core database"); $this->_tempFile = JoomlapackCUBETempfiles::registerTempFile(dechex(crc32(microtime() . 'joomla.sql'))); $this->_saveAsName = 'joomla.sql'; } else { // External databases, we use the database's name JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, "JoomlapackDumperDefault :: External database"); $this->_tempFile = JoomlapackCUBETempfiles::registerTempFile(dechex(crc32(microtime() . $this->_database . '.sql'))); $this->_saveAsName = $this->_database . '.sql'; } } break; } JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, "JoomlapackDomainDBBackup :: SQL temp file is " . $this->_tempFile); JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, "JoomlapackDomainDBBackup :: SQL file location in archive is " . $this->_saveAsName); }