1 | <?php |
||
21 | class Innobackupex extends Abstraction implements Executable |
||
22 | { |
||
23 | use OptionMasker; |
||
24 | |||
25 | /** |
||
26 | * MySQL data directory |
||
27 | * |
||
28 | * @var string |
||
29 | */ |
||
30 | private $dataDir; |
||
31 | |||
32 | /** |
||
33 | * Dump directory |
||
34 | * |
||
35 | * @var string |
||
36 | */ |
||
37 | private $dumpDir; |
||
38 | |||
39 | /** |
||
40 | * Host to connect to |
||
41 | * --host <hostname> |
||
42 | * |
||
43 | * @var string |
||
44 | */ |
||
45 | private $host; |
||
46 | |||
47 | /** |
||
48 | * User to connect with |
||
49 | * --user <username> |
||
50 | * |
||
51 | * @var string |
||
52 | */ |
||
53 | private $user; |
||
54 | |||
55 | /** |
||
56 | * Password to authenticate with |
||
57 | * --password <password> |
||
58 | * |
||
59 | * @var string |
||
60 | */ |
||
61 | private $password; |
||
62 | |||
63 | /** |
||
64 | * Regular expression matching the tables to be backed up. |
||
65 | * The regex should match the full qualified name: myDatabase.myTable |
||
66 | * --tables string |
||
67 | * |
||
68 | * @var string |
||
69 | */ |
||
70 | private $include; |
||
71 | |||
72 | /** |
||
73 | * List of databases and/or tables to backup |
||
74 | * Tables must e fully qualified: myDatabase.myTable |
||
75 | * --databases array of strings |
||
76 | * |
||
77 | 10 | * @var array |
|
78 | */ |
||
79 | 10 | private $databases; |
|
80 | 10 | ||
81 | 10 | /** |
|
82 | * Constructor. |
||
83 | * |
||
84 | * @param string $path |
||
85 | */ |
||
86 | public function __construct(string $path = '') |
||
87 | { |
||
88 | $this->setup('innobackupex', $path); |
||
89 | 9 | $this->setMaskCandidates(['password']); |
|
90 | } |
||
91 | 9 | ||
92 | 9 | /** |
|
93 | * Set MySQL data dir. |
||
94 | * |
||
95 | * @param string $path |
||
96 | * @return \phpbu\App\Cli\Executable\Innobackupex |
||
97 | */ |
||
98 | public function dumpFrom(string $path) : Innobackupex |
||
99 | { |
||
100 | $this->dataDir = $path; |
||
101 | 3 | return $this; |
|
102 | } |
||
103 | 3 | ||
104 | 3 | /** |
|
105 | * Set target dump dir. |
||
106 | * |
||
107 | * @param string $path |
||
108 | * @return \phpbu\App\Cli\Executable\Innobackupex |
||
109 | */ |
||
110 | public function dumpTo(string $path) : Innobackupex |
||
115 | |||
116 | 4 | /** |
|
117 | 4 | * Set host du connect to. |
|
118 | 4 | * |
|
119 | * @param string $host |
||
120 | * @return \phpbu\App\Cli\Executable\Innobackupex |
||
121 | */ |
||
122 | public function useHost(string $host) : Innobackupex |
||
127 | 3 | ||
128 | /** |
||
129 | 3 | * Set mysql credentials. |
|
130 | 3 | * |
|
131 | * @param string $user |
||
132 | * @param string $password |
||
133 | * @return \phpbu\App\Cli\Executable\Innobackupex |
||
134 | */ |
||
135 | public function credentials(string $user = '', string $password = '') : Innobackupex |
||
141 | 3 | ||
142 | 3 | /** |
|
143 | * Set include option |
||
144 | * |
||
145 | * @param string $include |
||
146 | * @return \phpbu\App\Cli\Executable\Innobackupex |
||
147 | */ |
||
148 | public function including(string $include) : Innobackupex |
||
153 | 10 | ||
154 | 1 | /** |
|
155 | * Set databases to dump. |
||
156 | 9 | * |
|
157 | 9 | * @param array $databases |
|
158 | 9 | * @return \phpbu\App\Cli\Executable\Innobackupex |
|
159 | 9 | */ |
|
160 | 9 | public function dumpDatabases(array $databases) |
|
165 | 8 | ||
166 | /** |
||
167 | 8 | * Innobackupex CommandLine generator. |
|
168 | * |
||
169 | 9 | * @return \SebastianFeldmann\Cli\CommandLine |
|
170 | 9 | * @throws \phpbu\App\Exception |
|
171 | 9 | */ |
|
172 | 9 | public function createCommandLine() : CommandLine |
|
202 | } |
||
203 |