/** * Writes out the initial details meta file for the backup * @param \mithra62\BackupPro\Backup\Details $details * @param string $file_path The full path to the backup file * @param string $backup_method The method used for the backup (needed for restore options) * @return \mithra62\BackupPro\Backup\Database */ public function writeDetails(\mithra62\BackupPro\Backup\Details $details, $file_path, $backup_method = 'files') { $path_parts = pathinfo($file_path); $details_path = $path_parts['dirname']; $file_name = $path_parts['basename']; $details->createDetailsFile($file_name, $details_path); $base_details = array('time_taken' => $this->getBackup()->getBackupTime(), 'created_date' => $this->getNow(), 'database_backup_type' => $backup_method, 'max_memory' => memory_get_peak_usage(), 'uncompressed_size' => $this->getTotalFileSize(), 'item_count' => $this->getTotalFiles(), 'backup_type' => 'files'); $details->addDetails($file_name, $details_path, $base_details); return $this; }
/** * Writes out the initial details meta file for the backup * @param \mithra62\BackupPro\Backup\Details $details * @param string $file_path The full path to the backup file * @param string $backup_method The method used for the backup (needed for restore options) * @return \mithra62\BackupPro\Backup\Database */ public function writeDetails(\mithra62\BackupPro\Backup\Details $details, $file_path, $backup_method = 'php') { $path_parts = pathinfo($file_path); $details_path = $path_parts['dirname']; $file_name = $path_parts['basename']; $details->createDetailsFile($file_name, $details_path); $base_details = array('time_taken' => $this->getBackup()->getBackupTime(), 'created_date' => $this->getNow(), 'database_backup_type' => $backup_method, 'max_memory' => memory_get_peak_usage(), 'file_size' => filesize($file_path)); $details->addDetails($file_name, $details_path, $base_details); if ($this->getTables()) { $meta_details = array(); $uncompressed_size = 0; foreach ($this->getTables() as $meta) { $uncompressed_size = $uncompressed_size + $meta['Data_length']; $meta_details[] = array('Name' => $meta['Name'], 'Rows' => $meta['Rows'], 'Avg_row_length' => $meta['Avg_row_length'], 'Data_length' => $meta['Name'], 'Auto_increment' => $meta['Auto_increment']); } $details->addDetails($file_name, $details_path, array('details' => $meta_details, 'item_count' => count($meta_details), 'uncompressed_size' => $uncompressed_size)); } return $this; }