PluginProbe ʕ •ᴥ•ʔ
WP STAGING – WordPress Backups, Restore, Migration & Clone / 3.3.3
WP STAGING – WordPress Backups, Restore, Migration & Clone v3.3.3
4.11.2 4.11.1 4.11.0 4.10.0 4.9.5 4.9.4 4.9.3 4.9.2 4.9.1 4.9.0 4.8.1 trunk 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.1.0 3.1.1 3.1.2 3.1.3 3.1.4 3.10.0 3.2.0 3.3.1 3.3.2 3.3.3 3.4.1 3.4.3 3.5.0 3.6.0 3.7.1 3.8.0 3.8.1 3.8.2 3.8.3 3.8.4 3.8.5 3.8.6 3.8.7 3.9.0 3.9.1 3.9.2 3.9.3 3.9.4 4.0.0 4.1.0 4.1.1 4.1.2 4.1.3 4.1.4 4.2.0 4.2.1 4.3.0 4.3.1 4.3.2 4.4.0 4.5.0 4.6.0 4.7.0 4.7.1 4.7.2 4.7.3 4.8.0
wp-staging / Backup / Dto / Job / JobBackupDataDto.php
wp-staging / Backup / Dto / Job Last commit date
JobBackupDataDto.php 2 years ago JobRestoreDataDto.php 2 years ago
JobBackupDataDto.php
790 lines
1 <?php
2
3 namespace WPStaging\Backup\Dto\Job;
4
5 use WPStaging\Backup\Dto\Interfaces\RemoteUploadDtoInterface;
6 use WPStaging\Backup\Dto\JobDataDto;
7 use WPStaging\Backup\Dto\Traits\IsExportingTrait;
8 use WPStaging\Backup\Dto\Traits\IsExcludingTrait;
9 use WPStaging\Backup\Dto\Traits\RemoteUploadTrait;
10 use WPStaging\Framework\Facades\Hooks;
11
12 class JobBackupDataDto extends JobDataDto implements RemoteUploadDtoInterface
13 {
14 use IsExportingTrait;
15 use IsExcludingTrait;
16 use RemoteUploadTrait;
17
18 /** @var string|null */
19 private $name;
20
21 /** @var array */
22 private $excludedDirectories = [];
23
24 /** @var int */
25 private $totalDirectories;
26
27 /** @var int The number of files in the backup index */
28 private $totalFiles;
29
30 /** @var array The number of files in backup parts */
31 private $filesInParts = [];
32
33 /** @var int The number of files the FilesystemScanner discovered */
34 private $discoveredFiles;
35
36 /** @var array The number of files the FilesystemScanner discovered in themes,plugins,muplugins,uploads,others */
37 private $discoveredFilesArray = [];
38
39 /** @var string */
40 private $databaseFile;
41
42 /**
43 * @var int If a file couldn't be processed in a single request,
44 * this property holds how many bytes were written thus far
45 * so that the backup can start writing from this byte onwards.
46 */
47 private $fileBeingBackupWrittenBytes;
48
49 /** @var int */
50 private $totalRowsBackup;
51
52 /** @var int */
53 private $tableRowsOffset = 0;
54
55 /** @var int */
56 private $totalRowsOfTableBeingBackup = 0;
57
58 /** @var int reset to PHP_INT_MIN for each table */
59 private $lastInsertId;
60
61 /** @var array */
62 private $tablesToBackup = [];
63
64 /** @var array */
65 private $nonWpTables = [];
66
67 /** @var int The size in bytes of the database in this backup */
68 private $databaseFileSize = 0;
69
70 /** @var int The size in bytes of the filesystem in this backup */
71 private $filesystemSize = 0;
72
73 /** @var int The number of requests that the Discovering Files task has executed so far */
74 private $discoveringFilesRequests = 0;
75
76 /** @var bool True if this backup should be repeated on a schedule, false if it should run only once. */
77 private $repeatBackupOnSchedule;
78
79 /** @var string The cron to repeat this backup, if scheduled. */
80 private $scheduleRecurrence;
81
82 /** @var array The hour and minute to repeat this backup, if scheduled. */
83 private $scheduleTime = [];
84
85 /** @var int How many backups to keep, if scheduled. */
86 private $scheduleRotation;
87
88 /** @var string The absolute path to this .wpstg file */
89 private $backupFilePath;
90
91 /** @var string If set, this backup was created as part of this schedule ID. */
92 private $scheduleId;
93
94 /** @var bool Should this scheduled backup be created right now. Matters only if this backup is repeated on schedule */
95 private $isCreateScheduleBackupNow;
96
97 /** @var array Site selected to backup */
98 private $sitesToBackup = [];
99
100 /**
101 * is network subsite or network main site backup
102 * @var bool */
103 private $isNetworkSiteBackup = false;
104
105 /** @var bool */
106 private $isMultipartBackup = false;
107
108 /** @var int */
109 private $maxMultipartBackupSize = 2147483647; // 2GB - 1 Byte
110
111 /**
112 * @var array
113 * Store max index for each category
114 */
115 private $fileBackupIndices = [];
116
117 /** @var int */
118 private $maxDbPartIndex = 0;
119
120 /** @var int */
121 private $currentMultipartFileInfoIndex = 0;
122
123 /** @var array */
124 private $multipartFilesInfo = [];
125
126 /**
127 * @var array<string, int>
128 * Store total size for each category
129 */
130 private $categorySizes = [];
131
132 /** @var string */
133 private $backupType;
134
135 /** @var int */
136 private $subsiteBlogId;
137
138 /**
139 * @return string|null
140 */
141 public function getName()
142 {
143 return $this->name;
144 }
145
146 /**
147 * Hydrated dynamically.
148 *
149 * @param string|null $name
150 */
151 public function setName($name)
152 {
153 $this->name = $name;
154 }
155
156 /**
157 * @return array|null
158 */
159 public function getExcludedDirectories()
160 {
161 return (array)$this->excludedDirectories;
162 }
163
164 public function setExcludedDirectories(array $excludedDirectories = [])
165 {
166 $this->excludedDirectories = $excludedDirectories;
167 }
168
169 /**
170 * @return int
171 */
172 public function getTotalDirectories()
173 {
174 return $this->totalDirectories;
175 }
176
177 /**
178 * @param int $totalDirectories
179 */
180 public function setTotalDirectories($totalDirectories)
181 {
182 $this->totalDirectories = $totalDirectories;
183 }
184
185 /**
186 * @return int
187 */
188 public function getTotalFiles()
189 {
190 return $this->totalFiles;
191 }
192
193 /**
194 * @param int $totalFiles
195 */
196 public function setTotalFiles($totalFiles)
197 {
198 $this->totalFiles = $totalFiles;
199 }
200
201 /**
202 * @return int
203 */
204 public function getDiscoveredFiles()
205 {
206 return $this->discoveredFiles;
207 }
208
209 /**
210 * @param int $discoveredFiles
211 */
212 public function setDiscoveredFiles($discoveredFiles)
213 {
214 $this->discoveredFiles = $discoveredFiles;
215 }
216
217 /**
218 * @return string
219 */
220 public function getDatabaseFile()
221 {
222 return $this->databaseFile;
223 }
224
225 /**
226 * @param string $databaseFile
227 */
228 public function setDatabaseFile($databaseFile)
229 {
230 $this->databaseFile = $databaseFile;
231 }
232
233 /**
234 * @return int
235 */
236 public function getTableRowsOffset()
237 {
238 return (int)$this->tableRowsOffset;
239 }
240
241 /**
242 * @param int $tableRowsOffset
243 */
244 public function setTableRowsOffset($tableRowsOffset)
245 {
246 $this->tableRowsOffset = (int)$tableRowsOffset;
247 }
248
249 /**
250 * @return int
251 */
252 public function getTotalRowsBackup()
253 {
254 return (int)$this->totalRowsBackup;
255 }
256
257 /**
258 * @param int $totalRowsBackup
259 */
260 public function setTotalRowsBackup($totalRowsBackup)
261 {
262 $this->totalRowsBackup = (int)$totalRowsBackup;
263 }
264
265 /**
266 * @return int
267 */
268 public function getFileBeingBackupWrittenBytes()
269 {
270 return (int)$this->fileBeingBackupWrittenBytes;
271 }
272
273 /**
274 * @param int $fileBeingBackupWrittenBytes
275 */
276 public function setFileBeingBackupWrittenBytes($fileBeingBackupWrittenBytes)
277 {
278 $this->fileBeingBackupWrittenBytes = (int)$fileBeingBackupWrittenBytes;
279 }
280
281 /**
282 * @return array
283 */
284 public function getTablesToBackup()
285 {
286 return (array)$this->tablesToBackup;
287 }
288
289 /**
290 * @param array $tablesToBackup
291 */
292 public function setTablesToBackup($tablesToBackup)
293 {
294 $this->tablesToBackup = (array)$tablesToBackup;
295 }
296
297 /**
298 * @return array
299 */
300 public function getNonWpTables()
301 {
302 return (array)$this->nonWpTables;
303 }
304
305 /**
306 * @param array $nonWpTables
307 */
308 public function setNonWpTables($nonWpTables)
309 {
310 $this->nonWpTables = (array)$nonWpTables;
311 }
312
313 /**
314 * @return int
315 */
316 public function getTotalRowsOfTableBeingBackup()
317 {
318 return (int)$this->totalRowsOfTableBeingBackup;
319 }
320
321 /**
322 * @param int $totalRowsOfTableBeingBackup
323 */
324 public function setTotalRowsOfTableBeingBackup($totalRowsOfTableBeingBackup)
325 {
326 $this->totalRowsOfTableBeingBackup = (int)$totalRowsOfTableBeingBackup;
327 }
328
329 /**
330 * @return int
331 */
332 public function getDatabaseFileSize()
333 {
334 return $this->databaseFileSize;
335 }
336
337 /**
338 * @param int $databaseFileSize
339 */
340 public function setDatabaseFileSize($databaseFileSize)
341 {
342 $this->databaseFileSize = $databaseFileSize;
343 }
344
345 /**
346 * @return int
347 */
348 public function getFilesystemSize()
349 {
350 return $this->filesystemSize;
351 }
352
353 /**
354 * @param int $filesystemSize
355 */
356 public function setFilesystemSize($filesystemSize)
357 {
358 $this->filesystemSize = $filesystemSize;
359 }
360
361 /**
362 * @return int
363 */
364 public function getDiscoveringFilesRequests()
365 {
366 return $this->discoveringFilesRequests;
367 }
368
369 /**
370 * @param int $discoveringFilesRequests
371 */
372 public function setDiscoveringFilesRequests($discoveringFilesRequests)
373 {
374 $this->discoveringFilesRequests = $discoveringFilesRequests;
375 }
376
377 /**
378 * @return bool
379 */
380 public function getRepeatBackupOnSchedule()
381 {
382 return $this->repeatBackupOnSchedule;
383 }
384
385 /**
386 * @param bool $repeatBackupOnSchedule
387 */
388 public function setRepeatBackupOnSchedule($repeatBackupOnSchedule)
389 {
390 $this->repeatBackupOnSchedule = $repeatBackupOnSchedule;
391 }
392
393 /**
394 * @see Cron For WP STAGING cron recurrences.
395 *
396 * @return string A WP STAGING cron schedule
397 */
398 public function getScheduleRecurrence()
399 {
400 return $this->scheduleRecurrence;
401 }
402
403 /**
404 * @param string $scheduleRecurrence
405 */
406 public function setScheduleRecurrence($scheduleRecurrence)
407 {
408 $this->scheduleRecurrence = $scheduleRecurrence;
409 }
410
411 /**
412 * @return array H:i time format, expected to be accurate to the site's timezone, example: 00:00
413 */
414 public function getScheduleTime()
415 {
416 return $this->scheduleTime;
417 }
418
419 /**
420 * @param array $scheduleTime Hour and Minute ['00', '00']
421 */
422 public function setScheduleTime(array $scheduleTime)
423 {
424 $this->scheduleTime = $scheduleTime;
425 }
426
427 /**
428 * @return int How many backups to keep, example: 1
429 */
430 public function getScheduleRotation()
431 {
432 return $this->scheduleRotation;
433 }
434
435 /**
436 * @param int $scheduleRotation
437 */
438 public function setScheduleRotation($scheduleRotation)
439 {
440 $this->scheduleRotation = $scheduleRotation;
441 }
442
443 /**
444 * @return string
445 */
446 public function getBackupFilePath()
447 {
448 return $this->backupFilePath;
449 }
450
451 /**
452 * @param string $backupFilePath
453 */
454 public function setBackupFilePath($backupFilePath)
455 {
456 $this->backupFilePath = $backupFilePath;
457 }
458
459 /**
460 * @return string
461 */
462 public function getScheduleId()
463 {
464 return $this->scheduleId;
465 }
466
467 /**
468 * @param string $scheduleId
469 */
470 public function setScheduleId($scheduleId)
471 {
472 $this->scheduleId = $scheduleId;
473 }
474
475 /**
476 * @return bool
477 */
478 public function getIsCreateScheduleBackupNow()
479 {
480 return $this->isCreateScheduleBackupNow;
481 }
482
483 /**
484 * @param bool $isCreateScheduleBackupNow
485 */
486 public function setIsCreateScheduleBackupNow($isCreateScheduleBackupNow)
487 {
488 $this->isCreateScheduleBackupNow = (bool)$isCreateScheduleBackupNow;
489 }
490
491 /**
492 * @return array|null
493 */
494 public function getSitesToBackup()
495 {
496 return (array)$this->sitesToBackup;
497 }
498
499 public function setSitesToBackup(array $sitesToBackup = [])
500 {
501 $this->sitesToBackup = $sitesToBackup;
502 }
503
504 /**
505 * @return bool
506 */
507 public function getIsMultipartBackup()
508 {
509 return Hooks::applyFilters('wpstg.backup.isMultipartBackup', $this->isMultipartBackup);
510 }
511
512 /**
513 * @param bool $isMultipartBackup
514 */
515 public function setIsMultipartBackup($isMultipartBackup)
516 {
517 $this->isMultipartBackup = $isMultipartBackup;
518 }
519
520 /**
521 * @return int
522 */
523 public function getMaxMultipartBackupSize()
524 {
525 return Hooks::applyFilters('wpstg.backup.maxMultipartBackupSize', $this->maxMultipartBackupSize);
526 }
527
528 /**
529 * @param int $maxMultipartBackupSize
530 */
531 public function setMaxMultipartBackupSize($maxMultipartBackupSize)
532 {
533 $this->maxMultipartBackupSize = $maxMultipartBackupSize;
534 }
535
536 /**
537 * @return array
538 */
539 public function getDiscoveredFilesArray()
540 {
541 return $this->discoveredFilesArray;
542 }
543
544 /**
545 * @param array $discoveredFiles
546 */
547 public function setDiscoveredFilesArray($discoveredFiles = [])
548 {
549 $this->discoveredFilesArray = $discoveredFiles;
550 }
551
552 /**
553 * @param string $category
554 * @return int
555 */
556 public function getDiscoveredFilesByCategory($category)
557 {
558 if (!array_key_exists($category, $this->discoveredFilesArray)) {
559 return 0;
560 }
561
562 return $this->discoveredFilesArray[$category];
563 }
564
565 /**
566 * @param string $category
567 * @param int $discoveredFiles
568 */
569 public function setDiscoveredFilesByCategory($category, $discoveredFiles)
570 {
571 $this->discoveredFilesArray[$category] = $discoveredFiles;
572 }
573
574 /**
575 * @return array
576 */
577 public function getFilesInParts()
578 {
579 return $this->filesInParts;
580 }
581
582 /**
583 * @param array $filesInParts
584 */
585 public function setFilesInParts($filesInParts = [])
586 {
587 $this->filesInParts = $filesInParts;
588 }
589
590 /**
591 * @param string $category
592 * @param int $categoryIndex
593 * @return int
594 */
595 public function getFilesInPart($category, $categoryIndex)
596 {
597 if (!array_key_exists($category, $this->filesInParts)) {
598 return 0;
599 }
600
601 if (!isset($this->filesInParts[$category][$categoryIndex])) {
602 return 0;
603 }
604
605 return $this->filesInParts[$category][$categoryIndex];
606 }
607
608 /**
609 * @param string $category
610 * @param int $categoryIndex
611 * @param int $files
612 */
613 public function setFilesInPart($category, $categoryIndex, $files)
614 {
615 if (!array_key_exists($category, $this->filesInParts)) {
616 $this->filesInParts[$category] = [];
617 }
618
619 $this->filesInParts[$category][$categoryIndex] = $files;
620 }
621
622 /**
623 * @return array
624 */
625 public function getFileBackupIndices()
626 {
627 return $this->fileBackupIndices;
628 }
629
630 /**
631 * @param array $fileBackupIndices
632 */
633 public function setFileBackupIndices($fileBackupIndices = [])
634 {
635 $this->fileBackupIndices = $fileBackupIndices;
636 }
637
638 /**
639 * @return int
640 */
641 public function getMaxDbPartIndex()
642 {
643 return $this->maxDbPartIndex;
644 }
645
646 /**
647 * @param int $maxDbPartIndex
648 */
649 public function setMaxDbPartIndex($maxDbPartIndex)
650 {
651 $this->maxDbPartIndex = $maxDbPartIndex;
652 }
653
654 /**
655 * @return int
656 */
657 public function getCurrentMultipartFileInfoIndex()
658 {
659 return $this->currentMultipartFileInfoIndex;
660 }
661
662 /**
663 * @param int $currentMultipartFileInfoIndex
664 */
665 public function setCurrentMultipartFileInfoIndex($currentMultipartFileInfoIndex)
666 {
667 $this->currentMultipartFileInfoIndex = $currentMultipartFileInfoIndex;
668 }
669
670 /**
671 * @return array
672 */
673 public function getMultipartFilesInfo()
674 {
675 return $this->multipartFilesInfo;
676 }
677
678 /**
679 * @param array $multipartFilesInfo
680 */
681 public function setMultipartFilesInfo($multipartFilesInfo)
682 {
683 $this->multipartFilesInfo = $multipartFilesInfo;
684 }
685
686 /**
687 * @param array $multipartFileInfo
688 */
689 public function addMultipartFileInfo($multipartFileInfo)
690 {
691 $this->multipartFilesInfo[] = $multipartFileInfo;
692 }
693
694 /**
695 * @param array $multipartFileInfo
696 * @param int $index
697 */
698 public function updateMultipartFileInfo($multipartFileInfo, $index)
699 {
700 $this->multipartFilesInfo[$index] = $multipartFileInfo;
701 }
702
703 /**
704 * @param int $lastInsertId
705 */
706 public function setLastInsertId($lastInsertId)
707 {
708 $this->lastInsertId = $lastInsertId;
709 }
710
711 /**
712 * @return int
713 */
714 public function getLastInsertId()
715 {
716 return $this->lastInsertId;
717 }
718
719 /**
720 * @param array<string, int> $categorySizes
721 */
722 public function setCategorySizes($categorySizes)
723 {
724 $this->categorySizes = $categorySizes;
725 }
726
727 /**
728 * @return array<string, int>
729 */
730 public function getCategorySizes()
731 {
732 return $this->categorySizes;
733 }
734
735 /**
736 * @param bool $isNetworkSiteBackup
737 * @return void
738 */
739 public function setIsNetworkSiteBackup(bool $isNetworkSiteBackup)
740 {
741 $this->isNetworkSiteBackup = $isNetworkSiteBackup;
742 }
743
744 /**
745 * @return bool
746 */
747 public function getIsNetworkSiteBackup(): bool
748 {
749 return (bool)$this->isNetworkSiteBackup;
750 }
751
752 /**
753 * @param string $backupType
754 * @return void
755 */
756 public function setBackupType(string $backupType)
757 {
758 $this->backupType = $backupType;
759 }
760
761 /**
762 * @return string
763 */
764 public function getBackupType(): string
765 {
766 return $this->backupType;
767 }
768
769 /**
770 * @param int|null $subsiteBlogId
771 * @return void
772 */
773 public function setSubsiteBlogId($subsiteBlogId)
774 {
775 $this->subsiteBlogId = $subsiteBlogId;
776 }
777
778 /**
779 * @return int
780 */
781 public function getSubsiteBlogId(): int
782 {
783 if (empty($this->subsiteBlogId)) {
784 $this->subsiteBlogId = get_current_blog_id();
785 }
786
787 return (int)$this->subsiteBlogId;
788 }
789 }
790