-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathRestoreBackupFilesLocalHandler.php
43 lines (38 loc) · 1.47 KB
/
RestoreBackupFilesLocalHandler.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
namespace DigipolisGent\Robo\Helpers\EventHandler\DefaultHandler;
use DigipolisGent\CommandBuilder\CommandBuilder;
use DigipolisGent\Robo\Helpers\EventHandler\AbstractBackupHandler;
use DigipolisGent\Robo\Helpers\Util\RemoteConfig;
use Symfony\Component\EventDispatcher\GenericEvent;
class RestoreBackupFilesLocalHandler extends AbstractBackupHandler
{
/**
* {@inheritDoc}
*/
public function handle(GenericEvent $event)
{
/** @var RemoteConfig $remoteConfig */
$remoteConfig = $event->getArgument('remoteConfig');
$remoteSettings = $remoteConfig->getRemoteSettings();
$localSettings = $event->getArgument('localSettings');
$filesBackupFile = $this->backupFileName('.tar.gz', $remoteSettings['time']);
return $this->taskExecStack()
->exec(
(string) CommandBuilder::create('rm')
->addFlag('rf')
->addArgument($localSettings['filesdir'] . '/*')
->addArgument($localSettings['filesdir'] . '/.??*')
)
->exec(
(string) CommandBuilder::create('tar')
->addFlag('xkz')
->addFlag('f', $filesBackupFile)
->addFlag('C', $localSettings['filesdir'])
)
->exec(
(string) CommandBuilder::create('rm')
->addFlag('f')
->addArgument($filesBackupFile)
);
}
}