1 | <?php |
||
20 | class Mongodump extends Abstraction implements Executable |
||
21 | { |
||
22 | use OptionMasker; |
||
23 | |||
24 | /** |
||
25 | * Dump Directory |
||
26 | * |
||
27 | * @var string |
||
28 | */ |
||
29 | private $dumpDir; |
||
30 | |||
31 | /** |
||
32 | * Use IPv6 |
||
33 | * --ipv6 |
||
34 | * |
||
35 | * @var boolean |
||
36 | */ |
||
37 | private $useIPv6; |
||
38 | |||
39 | /** |
||
40 | * Host to connect to |
||
41 | * --host <hostname:port> |
||
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 | * Database to use for authentication |
||
65 | * --authenticationDatabase <dbname> |
||
66 | * |
||
67 | * @var string |
||
68 | */ |
||
69 | private $authenticationDatabase; |
||
70 | |||
71 | /** |
||
72 | * List of databases to backup |
||
73 | * --db <database> |
||
74 | * |
||
75 | * @var array |
||
76 | */ |
||
77 | private $databases; |
||
78 | |||
79 | /** |
||
80 | * List of collections to backup |
||
81 | * --collection <collection> |
||
82 | * |
||
83 | * @var array |
||
84 | */ |
||
85 | private $collections; |
||
86 | |||
87 | /** |
||
88 | * List of collections to ignore |
||
89 | * --excludeCollections array of strings |
||
90 | * |
||
91 | * @var array |
||
92 | */ |
||
93 | private $excludeCollections; |
||
94 | |||
95 | /** |
||
96 | * List of prefixes to exclude collections |
||
97 | * --excludeCollectionWithPrefix array of strings |
||
98 | * |
||
99 | * @var array |
||
100 | */ |
||
101 | private $excludeCollectionsWithPrefix; |
||
102 | |||
103 | /** |
||
104 | * Constructor. |
||
105 | * |
||
106 | 12 | * @param string $path |
|
107 | */ |
||
108 | 12 | public function __construct(string $path = '') |
|
109 | 12 | { |
|
110 | 12 | $this->setup('mongodump', $path); |
|
111 | $this->setMaskCandidates(['password']); |
||
112 | } |
||
113 | |||
114 | /** |
||
115 | * Set path to dump to. |
||
116 | * |
||
117 | * @param string $path |
||
118 | 11 | * @return \phpbu\App\Cli\Executable\Mongodump |
|
119 | */ |
||
120 | 11 | public function dumpToDirectory(string $path) : Mongodump |
|
125 | |||
126 | /** |
||
127 | * Use ipv6 to connect. |
||
128 | * |
||
129 | * @param boolean $bool |
||
130 | 2 | * @return \phpbu\App\Cli\Executable\Mongodump |
|
131 | */ |
||
132 | 2 | public function useIpv6(bool $bool) : Mongodump |
|
137 | |||
138 | /** |
||
139 | * Set host to dump from. |
||
140 | * |
||
141 | * @param string $host |
||
142 | 2 | * @return \phpbu\App\Cli\Executable\Mongodump |
|
143 | */ |
||
144 | 2 | public function useHost(string $host) : Mongodump |
|
149 | |||
150 | /** |
||
151 | * Set credentials. |
||
152 | * |
||
153 | * @param string $user |
||
154 | * @param string $password |
||
155 | * @param string $authDatabase |
||
156 | 3 | * @return \phpbu\App\Cli\Executable\Mongodump |
|
157 | */ |
||
158 | 3 | public function credentials(string $user = '', string $password = '', string $authDatabase = '') : Mongodump |
|
165 | |||
166 | /** |
||
167 | * Dump only given databases. |
||
168 | * |
||
169 | * @param array $databases |
||
170 | 2 | * @return \phpbu\App\Cli\Executable\Mongodump |
|
171 | */ |
||
172 | 2 | public function dumpDatabases(array $databases) : Mongodump |
|
177 | |||
178 | /** |
||
179 | * Dump only given collections. |
||
180 | * |
||
181 | * @param array $collections |
||
182 | 2 | * @return \phpbu\App\Cli\Executable\Mongodump |
|
183 | */ |
||
184 | 2 | public function dumpCollections(array $collections) : Mongodump |
|
189 | |||
190 | /** |
||
191 | * Exclude collections. |
||
192 | * |
||
193 | * @param array $collections |
||
194 | 2 | * @return \phpbu\App\Cli\Executable\Mongodump |
|
195 | */ |
||
196 | 2 | public function excludeCollections(array $collections) : Mongodump |
|
201 | |||
202 | /** |
||
203 | * Exclude collections with given prefixes. |
||
204 | * |
||
205 | * @param array $prefixes |
||
206 | 2 | * @return \phpbu\App\Cli\Executable\Mongodump |
|
207 | */ |
||
208 | 2 | public function excludeCollectionsWithPrefix(array $prefixes) : Mongodump |
|
213 | |||
214 | /** |
||
215 | * Mongodump CommandLine generator. |
||
216 | * |
||
217 | * @return \SebastianFeldmann\Cli\CommandLine |
||
218 | 12 | * @throws \phpbu\App\Exception |
|
219 | */ |
||
220 | 12 | protected function createCommandLine() : CommandLine |
|
253 | } |
||
254 |