-
Notifications
You must be signed in to change notification settings - Fork 2
/
RemoveBackupRemoteHandler.php
40 lines (33 loc) · 1.4 KB
/
RemoveBackupRemoteHandler.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
<?php
namespace DigipolisGent\Robo\Helpers\EventHandler\DefaultHandler;
use DigipolisGent\CommandBuilder\CommandBuilder;
use DigipolisGent\Robo\Helpers\EventHandler\AbstractBackupHandler;
use DigipolisGent\Robo\Helpers\Util\RemoteConfig;
use DigipolisGent\Robo\Task\Deploy\Ssh\Auth\KeyFile;
use Symfony\Component\EventDispatcher\GenericEvent;
class RemoveBackupRemoteHandler extends AbstractBackupHandler
{
use \DigipolisGent\Robo\Helpers\Traits\RemoteDatabaseBackupTrait;
use \DigipolisGent\Robo\Helpers\Traits\RemoteFilesBackupTrait;
use \DigipolisGent\Robo\Task\Deploy\Tasks;
/**
* {@inheritDoc}
*/
public function handle(GenericEvent $event)
{
/** @var RemoteConfig $remoteConfig */
$remoteConfig = $event->getArgument('remoteConfig');
$remoteSettings = $remoteConfig->getRemoteSettings();
$timeouts = $event->getArgument('timeouts');
$backupDir = $remoteSettings['backupsdir'] . '/' . $remoteSettings['time'];
$collection = $this->collectionBuilder();
$collection->taskSsh($remoteConfig->getHost(), new KeyFile($remoteConfig->getUser(), $remoteConfig->getPrivateKeyFile()))
->timeout($timeouts['remove_backup'])
->exec(
(string) CommandBuilder::create('rm')
->addFlag('rf')
->addArgument($backupDir)
);
return $collection;
}
}