1 | <?php |
||
23 | class Sftp extends Xtp |
||
24 | { |
||
25 | /** |
||
26 | * @var phpseclib\Net\SFTP |
||
27 | */ |
||
28 | protected $sftp; |
||
29 | |||
30 | /** |
||
31 | * Remote path where to put the backup |
||
32 | * |
||
33 | * @var Path |
||
34 | */ |
||
35 | protected $remotePath; |
||
36 | |||
37 | /** |
||
38 | * Remote port of sftp server |
||
39 | * |
||
40 | * @var string |
||
41 | */ |
||
42 | protected $port; |
||
43 | |||
44 | /** |
||
45 | * @var int |
||
46 | */ |
||
47 | protected $time; |
||
48 | |||
49 | /** |
||
50 | * @var string |
||
51 | */ |
||
52 | protected $privateKey; |
||
53 | |||
54 | /** |
||
55 | * (non-PHPDoc) |
||
56 | * |
||
57 | * @see \phpbu\App\Backup\Sync::setup() |
||
58 | * @param array $config |
||
59 | * @throws \phpbu\App\Backup\Sync\Exception |
||
60 | * @throws \phpbu\App\Exception |
||
61 | */ |
||
62 | 12 | public function setup(array $config) |
|
86 | |||
87 | /** |
||
88 | * Check for required loaded libraries or extensions. |
||
89 | * |
||
90 | * @throws \phpbu\App\Backup\Sync\Exception |
||
91 | */ |
||
92 | 8 | protected function checkRequirements() |
|
98 | |||
99 | /** |
||
100 | * Return implemented (*)TP protocol name. |
||
101 | * |
||
102 | * @return string |
||
103 | */ |
||
104 | 1 | protected function getProtocolName() |
|
108 | |||
109 | /** |
||
110 | * (non-PHPDoc) |
||
111 | * |
||
112 | * @see \phpbu\App\Backup\Sync::sync() |
||
113 | * @param \phpbu\App\Backup\Target $target |
||
114 | * @param \phpbu\App\Result $result |
||
115 | * @throws \phpbu\App\Backup\Sync\Exception |
||
116 | */ |
||
117 | 4 | public function sync(Target $target, Result $result) |
|
144 | |||
145 | /** |
||
146 | * Create a sftp handle. |
||
147 | * |
||
148 | * @return \phpseclib\Net\SFTP |
||
149 | * @throws \phpbu\App\Backup\Sync\Exception |
||
150 | */ |
||
151 | protected function createClient() : phpseclib\Net\SFTP |
||
176 | |||
177 | /** |
||
178 | * If a relative path is configured, determine absolute path and update local remote. |
||
179 | * |
||
180 | * @throws \phpbu\App\Backup\Sync\Exception |
||
181 | */ |
||
182 | 4 | protected function validateRemotePath() |
|
189 | |||
190 | /** |
||
191 | * Return a phpseclib authentication thingy. |
||
192 | * |
||
193 | * @return \phpseclib\Crypt\RSA|string |
||
194 | */ |
||
195 | private function getAuth() |
||
208 | |||
209 | /** |
||
210 | * Return list of remote directories to travers. |
||
211 | * |
||
212 | * @return array |
||
213 | */ |
||
214 | 4 | private function getRemoteDirectoryList() : array |
|
218 | |||
219 | /** |
||
220 | * Creates collector for SFTP |
||
221 | * |
||
222 | * @param \phpbu\App\Backup\Target $target |
||
223 | * @return \phpbu\App\Backup\Collector |
||
224 | * @throws \phpbu\App\Backup\Sync\Exception |
||
225 | */ |
||
226 | 1 | protected function createCollector(Target $target): Collector |
|
230 | } |
||
231 |