1 | <?php |
||
22 | class Tar extends SimulatorExecutable implements Simulator |
||
23 | { |
||
24 | /** |
||
25 | * Tar Executable |
||
26 | * |
||
27 | * @var \phpbu\App\Cli\Executable\Tar |
||
28 | */ |
||
29 | protected $executable; |
||
30 | |||
31 | /** |
||
32 | * Path to executable. |
||
33 | * |
||
34 | * @var string |
||
35 | */ |
||
36 | private $pathToTar; |
||
37 | |||
38 | /** |
||
39 | * Path to backup |
||
40 | * |
||
41 | * @var string |
||
42 | */ |
||
43 | private $path; |
||
44 | |||
45 | /** |
||
46 | * Tar should ignore failed reads |
||
47 | * --ignore-failed-read |
||
48 | * |
||
49 | * @var boolean |
||
50 | */ |
||
51 | private $ignoreFailedRead; |
||
52 | |||
53 | /** |
||
54 | * Remove the packed data |
||
55 | * |
||
56 | * @var boolean |
||
57 | */ |
||
58 | private $removeSourceDir; |
||
59 | |||
60 | /** |
||
61 | * Compression to use. |
||
62 | * |
||
63 | * @var string |
||
64 | */ |
||
65 | private $compression; |
||
66 | |||
67 | /** |
||
68 | * Path where to store the archive. |
||
69 | * |
||
70 | * @var string |
||
71 | */ |
||
72 | private $pathToArchive; |
||
73 | |||
74 | /** |
||
75 | * Setup. |
||
76 | * |
||
77 | * @see \phpbu\App\Backup\Source |
||
78 | * @param array $conf |
||
79 | * @throws \phpbu\App\Exception |
||
80 | */ |
||
81 | 7 | public function setup(array $conf = []) |
|
82 | { |
||
83 | 7 | $this->pathToTar = Util\Arr::getValue($conf, 'pathToTar'); |
|
84 | 7 | $this->path = Util\Arr::getValue($conf, 'path'); |
|
85 | 7 | $this->ignoreFailedRead = Util\Str::toBoolean(Util\Arr::getValue($conf, 'ignoreFailedRead', ''), false); |
|
86 | 7 | $this->removeSourceDir = Util\Str::toBoolean(Util\Arr::getValue($conf, 'removeSourceDir', ''), false); |
|
87 | |||
88 | 7 | if (empty($this->path)) { |
|
89 | 1 | throw new Exception('path option is mandatory'); |
|
90 | } |
||
91 | 6 | } |
|
92 | |||
93 | /** |
||
94 | * Execute the backup. |
||
95 | * |
||
96 | * @see \phpbu\App\Backup\Source |
||
97 | * @param \phpbu\App\Backup\Target $target |
||
98 | * @param \phpbu\App\Result $result |
||
99 | * @return \phpbu\App\Backup\Source\Status |
||
100 | * @throws \phpbu\App\Exception |
||
101 | */ |
||
102 | 3 | public function backup(Target $target, Result $result) |
|
118 | |||
119 | /** |
||
120 | 2 | * Check if tar failed. |
|
121 | * |
||
122 | * @param \phpbu\App\Cli\Result $tar |
||
123 | * @return bool |
||
124 | */ |
||
125 | public function tarFailed(\phpbu\App\Cli\Result $tar) |
||
130 | |||
131 | 6 | /** |
|
132 | * Setup the Executable to run the 'tar' command. |
||
133 | 3 | * |
|
134 | 2 | * @param \phpbu\App\Backup\Target |
|
135 | 1 | * @return \phpbu\App\Cli\Executable |
|
136 | 1 | */ |
|
137 | public function getExecutable(Target $target) |
||
163 | |||
164 | /** |
||
165 | * Check the source to compress. |
||
166 | * |
||
167 | * @throws \phpbu\App\Exception |
||
168 | */ |
||
169 | private function validatePath() |
||
175 | |||
176 | /** |
||
177 | * Create backup status. |
||
178 | * |
||
179 | * @param \phpbu\App\Backup\Target |
||
180 | * @return \phpbu\App\Backup\Source\Status |
||
181 | */ |
||
182 | protected function createStatus(Target $target) |
||
191 | } |
||
192 |