public static function restore_from_file($backup_dir, $backup_file) { if (mkdir($backup_dir) === false) { throw new Sns_Exception_Unavailable_Operation('Cannot create the directory ' . $backup_dir); } self::restore_item($backup_file, $backup_dir); $options = Sns_Option::get_locations(); foreach ($options as $option => $to) { $item = $option == Sns_Option::DB ? $backup_dir . SNS_DS . 'wp_dump.sql' : $backup_dir . SNS_DS . $option . '.zip'; if (file_exists($item)) { if ($option == Sns_Option::DB) { Sns_Log::log_action('Restoring database'); try { Sns_Backup::import_db($item, true); } catch (Exception $e) { Sns_Log::log_exception_obj($e); } Sns_Log::log_action('Restoring database', SNS_LOG_END); } else { Sns_Log::log_action('Restoring item ' . $item); try { self::restore_item($item, $to); } catch (Exception $e) { Sns_Log::log_exception_obj($e); } Sns_Log::log_action('Restoring item ' . $item, SNS_LOG_END); } } } self::delete_dir($backup_dir); }