1 | <?php |
||
12 | class IMysqldump_Database_Backup_Engine extends Database_Backup_Engine { |
||
13 | |||
14 | public function __construct() { |
||
17 | |||
18 | /** |
||
19 | * Perform the database backupwordpress |
||
20 | * |
||
21 | * @return bool True if the backup completed successfully, else false. |
||
22 | */ |
||
23 | public function backup() { |
||
24 | |||
25 | try { |
||
26 | |||
27 | $dump = new IMysqldump\Mysqldump( $this->get_dsn(), $this->get_user(), $this->get_password(), $this->get_dump_settings() ); |
||
28 | $dump->start( $this->get_backup_filepath() ); |
||
29 | |||
30 | } catch ( \Exception $e ) { |
||
31 | $this->error( __CLASS__, $e->getMessage() ); |
||
32 | } |
||
33 | |||
34 | return $this->verify_backup(); |
||
35 | |||
36 | } |
||
37 | |||
38 | /** |
||
39 | * Get the settings for the database bump. |
||
40 | * |
||
41 | * @return array The array of database dump settings. |
||
42 | */ |
||
43 | public function get_dump_settings() { |
||
44 | |||
45 | /** |
||
46 | * Allow additional settings to be added. |
||
47 | * |
||
48 | * @param string[] $settings The array of settings. |
||
49 | * @todo can these be standardised across all database backup engines |
||
50 | */ |
||
51 | return apply_filters( 'hmbkp_imysqldump_command', array( |
||
52 | 'default-character-set' => $this->get_charset(), |
||
53 | 'hex-blob' => true, |
||
54 | 'single-transaction' => defined( 'HMBKP_MYSQLDUMP_SINGLE_TRANSACTION' ) && HMBKP_MYSQLDUMP_SINGLE_TRANSACTION |
||
55 | ) ); |
||
56 | |||
57 | } |
||
58 | |||
59 | /** |
||
60 | * Correctly calculates the DSN string for the various mysql |
||
61 | * connection variations including simplt hostname, non-standard ports |
||
62 | * and socket connections. |
||
63 | * |
||
64 | * @return string The DSN connection string |
||
65 | */ |
||
66 | public function get_dsn() { |
||
81 | |||
82 | } |
||
83 |