1 | <?php |
||
17 | class Backup |
||
18 | { |
||
19 | /** |
||
20 | * Backup name |
||
21 | * |
||
22 | * @var string |
||
23 | */ |
||
24 | private $name; |
||
25 | |||
26 | /** |
||
27 | * Stop all other backups on failure |
||
28 | * |
||
29 | * @var boolean |
||
30 | */ |
||
31 | private $stopOnFailure; |
||
32 | |||
33 | /** |
||
34 | * Source configuration |
||
35 | * |
||
36 | * @var \phpbu\App\Configuration\Backup\Source |
||
37 | */ |
||
38 | private $source; |
||
39 | |||
40 | /** |
||
41 | * Target configuration |
||
42 | * |
||
43 | * @var \phpbu\App\Configuration\Backup\Target |
||
44 | */ |
||
45 | private $target; |
||
46 | |||
47 | /** |
||
48 | * List of configured Checks |
||
49 | * |
||
50 | * @var array<\phpbu\App\Configuration\Backup\Check> |
||
51 | */ |
||
52 | private $checks = []; |
||
53 | |||
54 | /** |
||
55 | * Crypt configuration |
||
56 | * |
||
57 | * @var \phpbu\App\Configuration\Backup\Crypt |
||
58 | */ |
||
59 | private $crypt; |
||
60 | |||
61 | /** |
||
62 | * List of configured Syncs |
||
63 | * |
||
64 | * @var array<\phpbu\App\Configuration\Backup\Sync> |
||
65 | */ |
||
66 | private $syncs = []; |
||
67 | |||
68 | /** |
||
69 | * Cleanup configuration |
||
70 | * |
||
71 | * @var \phpbu\App\Configuration\Backup\Cleanup |
||
72 | */ |
||
73 | private $cleanup; |
||
74 | |||
75 | /** |
||
76 | * Constructor |
||
77 | * |
||
78 | * @param string $name |
||
79 | * @param boolean $stopOnFailure |
||
80 | */ |
||
81 | 30 | public function __construct($name, $stopOnFailure) |
|
82 | { |
||
83 | 30 | $this->name = $name; |
|
84 | 30 | $this->stopOnFailure = $stopOnFailure; |
|
85 | 30 | } |
|
86 | |||
87 | /** |
||
88 | * Returns name for the backup. |
||
89 | * |
||
90 | * @return string |
||
91 | * @throws \phpbu\App\Exception |
||
92 | */ |
||
93 | 12 | public function getName() |
|
94 | { |
||
95 | 12 | if (!empty($this->name)) { |
|
96 | 10 | return $this->name; |
|
97 | } |
||
98 | 2 | if (!empty($this->source)) { |
|
99 | 1 | return $this->source->type; |
|
100 | } |
||
101 | 1 | throw new Exception('no name and no source'); |
|
102 | } |
||
103 | |||
104 | /** |
||
105 | * StopOnFailure getter. |
||
106 | * |
||
107 | * @return boolean |
||
108 | */ |
||
109 | 1 | public function stopOnFailure() |
|
113 | |||
114 | /** |
||
115 | * Data source setter. |
||
116 | * |
||
117 | * @param \phpbu\App\Configuration\Backup\Source $source |
||
118 | */ |
||
119 | 14 | public function setSource(Backup\Source $source) |
|
123 | |||
124 | /** |
||
125 | * Source getter. |
||
126 | * |
||
127 | * @return \phpbu\App\Configuration\Backup\Source |
||
128 | */ |
||
129 | 3 | public function getSource() |
|
133 | |||
134 | /** |
||
135 | * Target setter. |
||
136 | * |
||
137 | * @param \phpbu\App\Configuration\Backup\Target $target |
||
138 | */ |
||
139 | 9 | public function setTarget(Backup\Target $target) |
|
143 | |||
144 | /** |
||
145 | * Target getter. |
||
146 | * |
||
147 | * @return \phpbu\App\Configuration\Backup\Target |
||
148 | */ |
||
149 | 1 | public function getTarget() |
|
153 | |||
154 | /** |
||
155 | * Adds a check to the list. |
||
156 | * |
||
157 | * @param \phpbu\App\Configuration\Backup\Check $check |
||
158 | */ |
||
159 | 9 | public function addCheck(Backup\Check $check) |
|
163 | |||
164 | /** |
||
165 | * Returns list of checks. |
||
166 | * |
||
167 | * @return array<\phpbu\App\Configuration\Backup\Check> |
||
168 | */ |
||
169 | 4 | public function getChecks() |
|
173 | |||
174 | /** |
||
175 | * Crypt setter. |
||
176 | * |
||
177 | * @param \phpbu\App\Configuration\Backup\Crypt $crypt |
||
178 | */ |
||
179 | 6 | public function setCrypt(Backup\Crypt $crypt) |
|
183 | |||
184 | /** |
||
185 | * Crypt getter. |
||
186 | * |
||
187 | * @return \phpbu\App\Configuration\Backup\Crypt |
||
188 | */ |
||
189 | 1 | public function getCrypt() |
|
193 | |||
194 | /** |
||
195 | * Is crypt set. |
||
196 | * |
||
197 | * @return bool |
||
198 | */ |
||
199 | 8 | public function hasCrypt() |
|
203 | |||
204 | /** |
||
205 | * Add sync to list. |
||
206 | * |
||
207 | * @param \phpbu\App\Configuration\Backup\Sync $sync |
||
208 | */ |
||
209 | 3 | public function addSync(Backup\Sync $sync) |
|
213 | |||
214 | /** |
||
215 | * Returns list of syncs. |
||
216 | * |
||
217 | * @return array<\phpbu\App\Configuration\Backup\Sync> |
||
218 | */ |
||
219 | 6 | public function getSyncs() |
|
223 | |||
224 | /** |
||
225 | * Cleanup setter. |
||
226 | * |
||
227 | * @param \phpbu\App\Configuration\Backup\Cleanup $cleanup |
||
228 | */ |
||
229 | 1 | public function setCleanup(Backup\Cleanup $cleanup) |
|
233 | |||
234 | /** |
||
235 | * Cleanup getter. |
||
236 | * |
||
237 | * @return \phpbu\App\Configuration\Backup\Cleanup |
||
238 | */ |
||
239 | public function getCleanup() |
||
243 | |||
244 | /** |
||
245 | * Is cleanup set. |
||
246 | * |
||
247 | * @return bool |
||
248 | */ |
||
249 | public function hasCleanup() |
||
253 | } |
||
254 |