quequiereshacer
Forum Replies Created
Viewing 1 replies (of 1 total)
-
Forum: Plugins
In reply to: [BackUpWordPress] Mysqldump custom socket pathHello again,
I send you the code of the modified function to handle a custom socket path configuration:
public function mysqldump() { $this->mysqldump_method = 'mysqldump'; $this->do_action( 'hmbkp_mysqldump_started' ); $host = explode( ':', DB_HOST ); $host = reset( $host ); $port = strpos( DB_HOST, ':' ) ? end( explode( ':', DB_HOST ) ) : ''; $socket = strpos( DB_HOST, ':' ) ? end( explode( ':', DB_HOST ) ) : ''; // Path to the mysqldump executable $cmd = escapeshellarg( $this->get_mysqldump_command_path() ); // We don't want to create a new DB $cmd .= ' --no-create-db'; // Allow lock-tables to be overridden if ( ! defined( 'HMBKP_MYSQLDUMP_SINGLE_TRANSACTION' ) || HMBKP_MYSQLDUMP_SINGLE_TRANSACTION !== false ) $cmd .= ' --single-transaction'; // Make sure binary data is exported properly $cmd .= ' --hex-blob'; // Username $cmd .= ' -u ' . escapeshellarg( DB_USER ); // Don't pass the password if it's blank if ( DB_PASSWORD ) $cmd .= ' -p' . escapeshellarg( DB_PASSWORD ); // Set the host $cmd .= ' -h ' . escapeshellarg( $host ); // Set the port if it was set if ( ! empty( $port ) && is_numeric( $port ) ) $cmd .= ' -P ' . $port; // Set the socket path if ( ! empty( $socket ) && !is_numeric( $socket ) ) $cmd .= ' --protocol=socket -S ' . $socket; // The file we're saving too $cmd .= ' -r ' . escapeshellarg( $this->get_database_dump_filepath() ); // The database we're dumping $cmd .= ' ' . escapeshellarg( DB_NAME ); // Pipe STDERR to STDOUT $cmd .= ' 2>&1'; // Store any returned data in an error $stderr = shell_exec( $cmd ); // Skip the new password warning that is output in mysql > 5.6 (@see http://bugs.mysql.com/bug.php?id=66546) if ( trim( $stderr ) === 'Warning: Using a password on the command line interface can be insecure.' ) { $stderr = ''; } if ( $stderr ) { $this->error( $this->get_mysqldump_method(), $stderr ); } $this->verify_mysqldump(); }
Viewing 1 replies (of 1 total)