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