@@ 194-214 (lines=21) @@ | ||
191 | * @param \phpbu\App\Backup\Target $target |
|
192 | * @throws \Exception |
|
193 | */ |
|
194 | protected function executeSyncs(Configuration\Backup $backup, Target $target) |
|
195 | { |
|
196 | /* @var \phpbu\App\Configuration\Backup\Sync $sync */ |
|
197 | foreach ($backup->getSyncs() as $config) { |
|
198 | try { |
|
199 | $this->result->syncStart($config); |
|
200 | if ($this->failure && $config->skipOnFailure) { |
|
201 | $this->result->syncSkipped($config); |
|
202 | return; |
|
203 | } |
|
204 | $sync = $this->factory->createSync($config->type, $config->options); |
|
205 | $sync->sync($target, $this->result); |
|
206 | $this->result->syncEnd($config); |
|
207 | ||
208 | } catch (Sync\Exception $e) { |
|
209 | $this->failure = true; |
|
210 | $this->result->addError($e); |
|
211 | $this->result->syncFailed($config); |
|
212 | } |
|
213 | } |
|
214 | } |
|
215 | ||
216 | /** |
|
217 | * Execute the cleanup. |
|
@@ 224-245 (lines=22) @@ | ||
221 | * @param \phpbu\App\Backup\Collector $collector |
|
222 | * @throws \phpbu\App\Exception |
|
223 | */ |
|
224 | protected function executeCleanup(Configuration\Backup $backup, Target $target, Collector $collector) |
|
225 | { |
|
226 | if ($backup->hasCleanup()) { |
|
227 | /* @var \phpbu\App\Configuration\Backup\Cleanup $config */ |
|
228 | $config = $backup->getCleanup(); |
|
229 | try { |
|
230 | $this->result->cleanupStart($config); |
|
231 | if ($this->failure && $config->skipOnFailure) { |
|
232 | $this->result->cleanupSkipped($config); |
|
233 | return; |
|
234 | } |
|
235 | $cleaner = $this->factory->createCleaner($config->type, $config->options); |
|
236 | $cleaner->cleanup($target, $collector, $this->result); |
|
237 | $this->result->cleanupEnd($config); |
|
238 | ||
239 | } catch (Cleaner\Exception $e) { |
|
240 | $this->failure = true; |
|
241 | $this->result->addError($e); |
|
242 | $this->result->cleanupFailed($config); |
|
243 | } |
|
244 | } |
|
245 | } |
|
246 | ||
247 | /** |
|
248 | * Execute the compressor. |
|
@@ 164-185 (lines=22) @@ | ||
161 | * @param \phpbu\App\Backup\Target $target |
|
162 | * @throws \phpbu\App\Exception |
|
163 | */ |
|
164 | protected function executeCrypt(Configuration\Backup $backup, Target $target) |
|
165 | { |
|
166 | if ($backup->hasCrypt()) { |
|
167 | $config = $backup->getCrypt(); |
|
168 | try { |
|
169 | $this->result->cryptStart($config); |
|
170 | if ($this->failure && $config->skipOnFailure) { |
|
171 | $this->result->cryptSkipped($config); |
|
172 | return; |
|
173 | } |
|
174 | $crypter = $this->factory->createCrypter($config->type, $config->options); |
|
175 | $crypter->crypt($target, $this->result); |
|
176 | $target->setCrypter($crypter); |
|
177 | $this->result->cryptEnd($config); |
|
178 | ||
179 | } catch (Crypter\Exception $e) { |
|
180 | $this->failure = true; |
|
181 | $this->result->addError($e); |
|
182 | $this->result->cryptFailed($config); |
|
183 | } |
|
184 | } |
|
185 | } |
|
186 | ||
187 | /** |
|
188 | * Execute all syncs. |