1 | <?php |
||
22 | class Redis extends SimulatorExecutable implements Simulator |
||
23 | { |
||
24 | /** |
||
25 | * Path to executable. |
||
26 | * |
||
27 | * @var string |
||
28 | */ |
||
29 | private $pathToRedisCli; |
||
30 | |||
31 | /** |
||
32 | * Time to wait for the dump to finish |
||
33 | * |
||
34 | * @var integer |
||
35 | */ |
||
36 | private $timeout; |
||
37 | |||
38 | /** |
||
39 | * Host to backup |
||
40 | * |
||
41 | * @var string |
||
42 | */ |
||
43 | private $host; |
||
44 | |||
45 | /** |
||
46 | * Port to connect to |
||
47 | * |
||
48 | * @var int |
||
49 | */ |
||
50 | private $port; |
||
51 | |||
52 | /** |
||
53 | * Password for authentication |
||
54 | * |
||
55 | * @var string |
||
56 | */ |
||
57 | private $password; |
||
58 | |||
59 | /** |
||
60 | * Path to the redis rdb directory, for Debian it's /var/lib/redis/{PORT}/dump.rdb |
||
61 | * |
||
62 | * @var string |
||
63 | */ |
||
64 | private $pathToRedisData; |
||
65 | |||
66 | /** |
||
67 | * Setup. |
||
68 | * |
||
69 | * @see \phpbu\App\Backup\Source |
||
70 | * @param array $conf |
||
71 | * @throws \phpbu\App\Exception |
||
72 | */ |
||
73 | public function setup(array $conf = []) |
||
86 | |||
87 | /** |
||
88 | 5 | * Execute the backup. |
|
89 | * |
||
90 | 5 | * @see \phpbu\App\Backup\Source |
|
91 | 5 | * @param \phpbu\App\Backup\Target $target |
|
92 | 5 | * @param \phpbu\App\Result $result |
|
93 | 5 | * @return \phpbu\App\Backup\Source\Status |
|
94 | 5 | * @throws \phpbu\App\Exception |
|
95 | 5 | */ |
|
96 | 5 | public function backup(Target $target, Result $result) |
|
117 | 3 | ||
118 | 3 | /** |
|
119 | 3 | * Setup the Executable to run the 'tar' command. |
|
120 | * |
||
121 | 3 | * @param \phpbu\App\Backup\Target |
|
122 | * @return \phpbu\App\Cli\Executable\RedisCli |
||
123 | 3 | */ |
|
124 | 3 | public function getExecutable(Target $target) |
|
135 | |||
136 | /** |
||
137 | * Creates a RedisLastSave command from a RedisSave command. |
||
138 | * |
||
139 | * @param \phpbu\App\Cli\Executable\RedisCli $redis |
||
140 | * @return \phpbu\App\Cli\Executable\RedisCli |
||
141 | 4 | */ |
|
142 | public function getRedisLastSave(Executable\RedisCli $redis) |
||
148 | 1 | ||
149 | 1 | /** |
|
150 | 1 | * Return last successful save timestamp. |
|
151 | 4 | * |
|
152 | * @param \phpbu\App\Cli\Executable\RedisCli $redis |
||
153 | * @return int |
||
154 | * @throws \phpbu\App\Exception |
||
155 | */ |
||
156 | private function getLastBackupTime(Executable\RedisCli $redis) |
||
166 | 3 | ||
167 | /** |
||
168 | * Check the dump date and return true if BGSAVE is finished. |
||
169 | 3 | * |
|
170 | * @param int $lastTimestamp |
||
171 | * @param \phpbu\App\Cli\Executable\RedisCli $redis |
||
172 | * @return bool |
||
173 | * @throws \phpbu\App\Exception |
||
174 | */ |
||
175 | private function isDumpCreatedYet($lastTimestamp, $redis) |
||
187 | 1 | ||
188 | 1 | /** |
|
189 | 1 | * Copy the redis RDB file to its backup location. |
|
190 | 1 | * |
|
191 | * @param \phpbu\App\Backup\Target $target |
||
192 | * @return string |
||
193 | * @throws \phpbu\App\Exception |
||
194 | */ |
||
195 | private function copyDumpToTarget(Target $target) |
||
204 | |||
205 | 1 | /** |
|
206 | 1 | * Create backup status. |
|
207 | 1 | * |
|
208 | * @param \phpbu\App\Backup\Target |
||
209 | * @return \phpbu\App\Backup\Source\Status |
||
210 | */ |
||
211 | protected function createStatus(Target $target) |
||
215 | } |
||
216 |