Advertisement
Guest User

Untitled

a guest
Apr 25th, 2017
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. <?php
  2.  
  3. ini_set('display_errors', 1);
  4. error_reporting(-1);
  5.  
  6. define('AREA', 'A');
  7. define('ACCOUNT_TYPE', 'admin');
  8.  
  9. try {
  10. require(dirname(__FILE__) . '/init.php');
  11.  
  12. $output = array();
  13. $exit_code = -1;
  14. $config = \Tygh\Registry::get('config');
  15. $tmp_path = $config['dir']['backups'] . '/mysqldump_speed_test_'.TIME.'.sql';
  16.  
  17. while(file_exists($tmp_path)) {
  18. $tmp_path = $config['dir']['backups'] . '/mysqldump_speed_test_'.TIME.rand().'.sql';
  19. }
  20.  
  21. $start = microtime(true);
  22. exec(sprintf('mysqldump'
  23. . ' --skip-add-locks'
  24. . ' --skip-set-charset'
  25. . ' --skip-disable-keys'
  26. . ' --skip-comments'
  27. . ' --skip-opt'
  28. . ' --skip-tz-utc'
  29. . ' --no-create-db'
  30. . ' --add-drop-table'
  31. . ' --create-options'
  32. . ' --complete-insert'
  33. . ' --skip-extended-insert'
  34. . ' --default-character-set=%s'
  35. . ' --user=%s'
  36. . ' --password=%s'
  37. . ' --host=%s'
  38. . ' --result-file=%s'
  39. . ' %s'
  40. . ' 2>&1',
  41. escapeshellarg('utf8'),
  42. escapeshellarg($config['db_user']),
  43. escapeshellarg($config['db_password']),
  44. escapeshellarg($config['db_host']),
  45. escapeshellarg($tmp_path),
  46. escapeshellarg($config['db_name'])
  47. ), $output, $exit_code);
  48.  
  49. $diff = microtime(true) - $start;
  50. $output = implode('<br>', $output);
  51.  
  52. fn_echo("Output: {$output}<br>Exit code: {$exit_code}<br>Time (microseconds): {$diff}<br>");
  53.  
  54. if (file_exists($tmp_path)) {
  55. fn_rm($tmp_path);
  56. }
  57. exit;
  58. } catch (Tygh\Exceptions\AException $e) {
  59. $e->output();
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement