Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- ini_set('display_errors', 1);
- error_reporting(-1);
- define('AREA', 'A');
- define('ACCOUNT_TYPE', 'admin');
- try {
- require(dirname(__FILE__) . '/init.php');
- $output = array();
- $exit_code = -1;
- $config = \Tygh\Registry::get('config');
- $tmp_path = $config['dir']['backups'] . '/mysqldump_speed_test_'.TIME.'.sql';
- while(file_exists($tmp_path)) {
- $tmp_path = $config['dir']['backups'] . '/mysqldump_speed_test_'.TIME.rand().'.sql';
- }
- $start = microtime(true);
- exec(sprintf('mysqldump'
- . ' --skip-add-locks'
- . ' --skip-set-charset'
- . ' --skip-disable-keys'
- . ' --skip-comments'
- . ' --skip-opt'
- . ' --skip-tz-utc'
- . ' --no-create-db'
- . ' --add-drop-table'
- . ' --create-options'
- . ' --complete-insert'
- . ' --skip-extended-insert'
- . ' --default-character-set=%s'
- . ' --user=%s'
- . ' --password=%s'
- . ' --host=%s'
- . ' --result-file=%s'
- . ' %s'
- . ' 2>&1',
- escapeshellarg('utf8'),
- escapeshellarg($config['db_user']),
- escapeshellarg($config['db_password']),
- escapeshellarg($config['db_host']),
- escapeshellarg($tmp_path),
- escapeshellarg($config['db_name'])
- ), $output, $exit_code);
- $diff = microtime(true) - $start;
- $output = implode('<br>', $output);
- fn_echo("Output: {$output}<br>Exit code: {$exit_code}<br>Time (microseconds): {$diff}<br>");
- if (file_exists($tmp_path)) {
- fn_rm($tmp_path);
- }
- exit;
- } catch (Tygh\Exceptions\AException $e) {
- $e->output();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement