PluginProbe ʕ •ᴥ•ʔ
WP STAGING – WordPress Backups, Restore, Migration & Clone / 4.11.0
WP STAGING – WordPress Backups, Restore, Migration & Clone v4.11.0
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 1 day ago JobRestoreDataDto.php 1 day ago
JobBackupDataDto.php
1212 lines
1 <?php
2
3 namespace WPStaging\Backup\Dto\Job;
4
5 use WPStaging\Backup\Dto\Interfaces\RemoteUploadDtoInterface;
6 use WPStaging\Backup\Dto\Traits\IsExportingTrait;
7 use WPStaging\Backup\Dto\Traits\IsExcludingTrait;
8 use WPStaging\Backup\Dto\Traits\RemoteUploadTrait;
9 use WPStaging\Backup\Entity\BackupMetadata;
10 use WPStaging\Framework\Facades\Hooks;
11 use WPStaging\Framework\Job\Dto\JobDataDto;
12
13 class JobBackupDataDto extends JobDataDto implements RemoteUploadDtoInterface
14 {
15 use IsExportingTrait;
16 use IsExcludingTrait;
17 use RemoteUploadTrait;
18
19
20 private $name;
21
22
23 private $isBeforeUpdateBackup = false;
24
25
26 private $excludedDirectories = [];
27
28
29 private $totalDirectories;
30
31
32 private $totalFiles;
33
34
35 private $filesInParts = [];
36
37
38 private $discoveredFiles = 0;
39
40
41 private $discoveredFilesArray = [];
42
43
44 private $invalidFiles = 0;
45
46
47 private $databaseFile;
48
49
50
51
52
53
54 private $fileBeingBackupWrittenBytes;
55
56
57
58
59 private $currentWrittenFileHeaderBytes = 0;
60
61
62
63
64 private $currentFileStartOffset = 0;
65
66
67 private $totalRowsBackup = 0;
68
69
70 private $tableRowsOffset = 0;
71
72
73 private $sqlCheckpointFile = '';
74
75
76 private $sqlWrittenBytes = 0;
77
78
79 private $totalRowsOfTableBeingBackup = 0;
80
81
82 private $lastInsertId = PHP_INT_MIN;
83
84
85 private $tablesToBackup = [];
86
87
88 private $nonWpTables = [];
89
90
91 private $databaseFileSize = 0;
92
93
94 private $filesystemSize = 0;
95
96
97 private $discoveringFilesRequests = 0;
98
99
100 private $scheduleRecurrence = '';
101
102
103 private $scheduleTime = [];
104
105
106 private $scheduleRotation = 0;
107
108
109 private $backupFilePath = '';
110
111
112 private $scheduleId = '';
113
114
115 private $isValidateBackupFiles = false;
116
117
118 private $isCreateScheduleBackupNow = false;
119
120
121 private $isCreateBackupInBackground = false;
122
123
124 private $sitesToBackup = [];
125
126
127
128
129 private $isNetworkSiteBackup = false;
130
131
132
133
134
135 private $fileBackupIndices = [];
136
137
138 private $maxDbPartIndex = 0;
139
140
141
142
143
144
145
146 private $bigFileSourceBytesWritten = 0;
147
148
149
150
151
152
153 private $bigFileIsContinuation = false;
154
155
156 private $currentMultipartFileInfoIndex = 0;
157
158
159 private $multipartFilesInfo = [];
160
161
162
163
164
165 private $categorySizes = [];
166
167
168 private $backupType = '';
169
170
171 private $subsiteBlogId = 0;
172
173
174 private $filePartIndex = 0;
175
176
177 private $isContaining2GBFile = false;
178
179
180 private $isGlitchInBackup = false;
181
182
183 private $glitchReason = '';
184
185
186 private $fileAppendTimeLimit = 10;
187
188
189 private $isCompressed = false;
190
191
192
193
194 private $backupSizeUncompressed = 0;
195
196
197
198
199 private $backupSizeCompressed = 0;
200
201
202
203
204 private $totalFilesCompressed = 0;
205
206
207 private $pushPrepareData = [];
208
209
210
211
212 public function isScheduledBackup(): bool
213 {
214 return $this->getRepeatBackupOnSchedule() || !empty($this->getScheduleId());
215 }
216
217
218
219
220 public function getName()
221 {
222 return $this->name;
223 }
224
225
226
227
228
229
230 public function setName($name)
231 {
232 $this->name = $name;
233 }
234
235
236
237
238 public function getIsBeforeUpdateBackup(): bool
239 {
240 return $this->isBeforeUpdateBackup;
241 }
242
243
244
245
246
247 public function setIsBeforeUpdateBackup(bool $isBeforeUpdateBackup)
248 {
249 $this->isBeforeUpdateBackup = $isBeforeUpdateBackup;
250 }
251
252
253
254
255 public function getPushPrepareData(): array
256 {
257 return $this->pushPrepareData;
258 }
259
260
261
262
263
264 public function setPushPrepareData(array $pushPrepareData)
265 {
266 $this->pushPrepareData = $pushPrepareData;
267 }
268
269
270
271
272 public function getExcludedDirectories()
273 {
274 return (array)$this->excludedDirectories;
275 }
276
277 public function setExcludedDirectories(array $excludedDirectories = [])
278 {
279 $this->excludedDirectories = $excludedDirectories;
280 }
281
282
283
284
285 public function getTotalDirectories()
286 {
287 return $this->totalDirectories;
288 }
289
290
291
292
293 public function setTotalDirectories($totalDirectories)
294 {
295 $this->totalDirectories = $totalDirectories;
296 }
297
298
299
300
301 public function getTotalFiles()
302 {
303 return $this->totalFiles;
304 }
305
306
307
308
309 public function setTotalFiles($totalFiles)
310 {
311 $this->totalFiles = $totalFiles;
312 }
313
314
315
316
317 public function getDiscoveredFiles()
318 {
319 return $this->discoveredFiles;
320 }
321
322
323
324
325 public function setDiscoveredFiles($discoveredFiles)
326 {
327 $this->discoveredFiles = $discoveredFiles;
328 }
329
330
331
332
333 public function getInvalidFiles(): int
334 {
335 return $this->invalidFiles;
336 }
337
338
339
340
341
342 public function setInvalidFiles(int $invalidFiles)
343 {
344 $this->invalidFiles = $invalidFiles;
345 }
346
347
348
349
350 public function incrementInvalidFiles()
351 {
352 $this->invalidFiles++;
353 }
354
355
356
357
358 public function getDatabaseFile()
359 {
360 return $this->databaseFile;
361 }
362
363
364
365
366 public function setDatabaseFile($databaseFile)
367 {
368 $this->databaseFile = $databaseFile;
369 }
370
371
372
373
374 public function getTableRowsOffset()
375 {
376 return (int)$this->tableRowsOffset;
377 }
378
379
380
381
382 public function setTableRowsOffset($tableRowsOffset)
383 {
384 $this->tableRowsOffset = (int)$tableRowsOffset;
385 }
386
387
388
389
390 public function getSqlCheckpointFile()
391 {
392 return (string)$this->sqlCheckpointFile;
393 }
394
395
396
397
398 public function setSqlCheckpointFile($sqlCheckpointFile)
399 {
400 $this->sqlCheckpointFile = (string)$sqlCheckpointFile;
401 }
402
403
404
405
406 public function getSqlWrittenBytes()
407 {
408 return (int)$this->sqlWrittenBytes;
409 }
410
411
412
413
414 public function setSqlWrittenBytes($sqlWrittenBytes)
415 {
416 $this->sqlWrittenBytes = (int)$sqlWrittenBytes;
417 }
418
419
420
421
422 public function getTotalRowsBackup()
423 {
424 return (int)$this->totalRowsBackup;
425 }
426
427
428
429
430 public function setTotalRowsBackup($totalRowsBackup)
431 {
432 $this->totalRowsBackup = (int)$totalRowsBackup;
433 }
434
435
436
437
438 public function getFileBeingBackupWrittenBytes()
439 {
440 return (int)$this->fileBeingBackupWrittenBytes;
441 }
442
443
444
445
446 public function setFileBeingBackupWrittenBytes($fileBeingBackupWrittenBytes)
447 {
448 $this->fileBeingBackupWrittenBytes = (int)$fileBeingBackupWrittenBytes;
449 }
450
451
452
453
454 public function getTablesToBackup()
455 {
456 return (array)$this->tablesToBackup;
457 }
458
459
460
461
462 public function setTablesToBackup($tablesToBackup)
463 {
464 $this->tablesToBackup = (array)$tablesToBackup;
465 }
466
467
468
469
470 public function getNonWpTables()
471 {
472 return (array)$this->nonWpTables;
473 }
474
475
476
477
478 public function setNonWpTables($nonWpTables)
479 {
480 $this->nonWpTables = (array)$nonWpTables;
481 }
482
483
484
485
486 public function getTotalRowsOfTableBeingBackup()
487 {
488 return (int)$this->totalRowsOfTableBeingBackup;
489 }
490
491
492
493
494 public function setTotalRowsOfTableBeingBackup($totalRowsOfTableBeingBackup)
495 {
496 $this->totalRowsOfTableBeingBackup = (int)$totalRowsOfTableBeingBackup;
497 }
498
499
500
501
502 public function getDatabaseFileSize()
503 {
504 return $this->databaseFileSize;
505 }
506
507
508
509
510 public function setDatabaseFileSize($databaseFileSize)
511 {
512 $this->databaseFileSize = $databaseFileSize;
513 }
514
515
516
517
518 public function getFilesystemSize()
519 {
520 return $this->filesystemSize;
521 }
522
523
524
525
526 public function setFilesystemSize($filesystemSize)
527 {
528 $this->filesystemSize = $filesystemSize;
529 }
530
531
532
533
534 public function getDiscoveringFilesRequests()
535 {
536 return $this->discoveringFilesRequests;
537 }
538
539
540
541
542 public function setDiscoveringFilesRequests($discoveringFilesRequests)
543 {
544 $this->discoveringFilesRequests = $discoveringFilesRequests;
545 }
546
547
548
549
550
551
552 public function getScheduleRecurrence()
553 {
554 return $this->scheduleRecurrence;
555 }
556
557
558
559
560 public function setScheduleRecurrence($scheduleRecurrence)
561 {
562 $this->scheduleRecurrence = $scheduleRecurrence;
563 }
564
565
566
567
568 public function getScheduleTime()
569 {
570 return $this->scheduleTime;
571 }
572
573
574
575
576 public function setScheduleTime(array $scheduleTime)
577 {
578 $this->scheduleTime = $scheduleTime;
579 }
580
581
582
583
584 public function getScheduleRotation()
585 {
586 return $this->scheduleRotation;
587 }
588
589
590
591
592 public function setScheduleRotation($scheduleRotation)
593 {
594 $this->scheduleRotation = $scheduleRotation;
595 }
596
597
598
599
600 public function getBackupFilePath()
601 {
602 return $this->backupFilePath;
603 }
604
605
606
607
608 public function setBackupFilePath($backupFilePath)
609 {
610 $this->backupFilePath = $backupFilePath;
611 }
612
613
614
615
616 public function getScheduleId()
617 {
618 return $this->scheduleId;
619 }
620
621
622
623
624 public function setScheduleId($scheduleId)
625 {
626 $this->scheduleId = $scheduleId;
627 }
628
629
630
631
632 public function getIsCreateScheduleBackupNow()
633 {
634 return $this->isCreateScheduleBackupNow;
635 }
636
637
638
639
640 public function setIsCreateScheduleBackupNow($isCreateScheduleBackupNow)
641 {
642 $this->isCreateScheduleBackupNow = (bool)$isCreateScheduleBackupNow;
643 }
644
645
646
647
648 public function getIsCreateBackupInBackground(): bool
649 {
650 return (bool)$this->isCreateBackupInBackground;
651 }
652
653
654
655
656
657 public function setIsCreateBackupInBackground($isCreateBackupInBackground)
658 {
659 $this->isCreateBackupInBackground = (bool)$isCreateBackupInBackground;
660 }
661
662
663
664
665 public function getSitesToBackup()
666 {
667 return (array)$this->sitesToBackup;
668 }
669
670 public function setSitesToBackup(array $sitesToBackup = [])
671 {
672 $this->sitesToBackup = $sitesToBackup;
673 }
674
675
676
677
678 public function getDiscoveredFilesArray()
679 {
680 return $this->discoveredFilesArray;
681 }
682
683
684
685
686 public function setDiscoveredFilesArray($discoveredFiles = [])
687 {
688 $this->discoveredFilesArray = $discoveredFiles;
689 }
690
691
692
693
694
695 public function getDiscoveredFilesByCategory($category)
696 {
697 if (!array_key_exists($category, $this->discoveredFilesArray)) {
698 return 0;
699 }
700
701 return $this->discoveredFilesArray[$category];
702 }
703
704
705
706
707
708 public function setDiscoveredFilesByCategory($category, $discoveredFiles)
709 {
710 $this->discoveredFilesArray[$category] = $discoveredFiles;
711 }
712
713
714
715
716 public function getFilesInParts()
717 {
718 return $this->filesInParts;
719 }
720
721
722
723
724 public function setFilesInParts($filesInParts = [])
725 {
726 $this->filesInParts = $filesInParts;
727 }
728
729
730
731
732
733
734 public function getFilesInPart($category, $categoryIndex)
735 {
736 if (!array_key_exists($category, $this->filesInParts)) {
737 return 0;
738 }
739
740 if (!isset($this->filesInParts[$category][$categoryIndex])) {
741 return 0;
742 }
743
744 return $this->filesInParts[$category][$categoryIndex];
745 }
746
747
748
749
750
751
752 public function setFilesInPart($category, $categoryIndex, $files)
753 {
754 if (!array_key_exists($category, $this->filesInParts)) {
755 $this->filesInParts[$category] = [];
756 }
757
758 $this->filesInParts[$category][$categoryIndex] = $files;
759 }
760
761
762
763
764
765
766 public function incrementFilesInPart(string $category, int $categoryIndex = 0)
767 {
768 if (!array_key_exists($category, $this->filesInParts)) {
769 $this->filesInParts[$category] = [];
770 }
771
772 if (!array_key_exists($categoryIndex, $this->filesInParts[$category])) {
773 $this->filesInParts[$category][$categoryIndex] = 0;
774 }
775
776 $this->filesInParts[$category][$categoryIndex]++;
777 }
778
779
780
781
782 public function getFileBackupIndices()
783 {
784 return $this->fileBackupIndices;
785 }
786
787
788
789
790 public function setFileBackupIndices($fileBackupIndices = [])
791 {
792 $this->fileBackupIndices = $fileBackupIndices;
793 }
794
795
796
797
798 public function getMaxDbPartIndex()
799 {
800 return $this->maxDbPartIndex;
801 }
802
803
804
805
806 public function setMaxDbPartIndex($maxDbPartIndex)
807 {
808 $this->maxDbPartIndex = $maxDbPartIndex;
809 }
810
811 public function getBigFileSourceBytesWritten(): int
812 {
813 return (int) $this->bigFileSourceBytesWritten;
814 }
815
816 public function setBigFileSourceBytesWritten(int $bigFileSourceBytesWritten)
817 {
818 $this->bigFileSourceBytesWritten = $bigFileSourceBytesWritten;
819 }
820
821 public function getBigFileIsContinuation(): bool
822 {
823 return (bool) $this->bigFileIsContinuation;
824 }
825
826 public function setBigFileIsContinuation(bool $bigFileIsContinuation)
827 {
828 $this->bigFileIsContinuation = $bigFileIsContinuation;
829 }
830
831
832
833
834 public function getCurrentMultipartFileInfoIndex()
835 {
836 return $this->currentMultipartFileInfoIndex;
837 }
838
839
840
841
842 public function setCurrentMultipartFileInfoIndex($currentMultipartFileInfoIndex)
843 {
844 $this->currentMultipartFileInfoIndex = $currentMultipartFileInfoIndex;
845 }
846
847
848
849
850 public function getMultipartFilesInfo()
851 {
852 return $this->multipartFilesInfo;
853 }
854
855
856
857
858 public function setMultipartFilesInfo($multipartFilesInfo)
859 {
860 $this->multipartFilesInfo = $multipartFilesInfo;
861 }
862
863
864
865
866 public function addMultipartFileInfo($multipartFileInfo)
867 {
868 $this->multipartFilesInfo[] = $multipartFileInfo;
869 }
870
871
872
873
874
875 public function updateMultipartFileInfo($multipartFileInfo, $index)
876 {
877 $this->multipartFilesInfo[$index] = $multipartFileInfo;
878 }
879
880
881
882
883 public function setLastInsertId($lastInsertId)
884 {
885 $this->lastInsertId = $lastInsertId;
886 }
887
888
889
890
891 public function getLastInsertId()
892 {
893 return $this->lastInsertId;
894 }
895
896
897
898
899 public function setCategorySizes($categorySizes)
900 {
901 $this->categorySizes = $categorySizes;
902 }
903
904
905
906
907 public function getCategorySizes()
908 {
909 return $this->categorySizes;
910 }
911
912
913
914
915 public function getFilePartIndex(): int
916 {
917 return $this->filePartIndex;
918 }
919
920
921
922
923
924 public function setFilePartIndex(int $index = 0)
925 {
926 $this->filePartIndex = $index;
927 }
928
929
930
931
932
933 public function setIsNetworkSiteBackup(bool $isNetworkSiteBackup)
934 {
935 $this->isNetworkSiteBackup = $isNetworkSiteBackup;
936 }
937
938
939
940
941 public function getIsNetworkSiteBackup(): bool
942 {
943 return (bool)$this->isNetworkSiteBackup;
944 }
945
946
947
948
949
950 public function setBackupType(string $backupType)
951 {
952 $this->backupType = $backupType;
953 }
954
955
956
957
958 public function getBackupType(): string
959 {
960 return $this->backupType;
961 }
962
963
964
965
966
967 public function setSubsiteBlogId($subsiteBlogId)
968 {
969 $this->subsiteBlogId = $subsiteBlogId;
970 }
971
972
973
974
975 public function getSubsiteBlogId(): int
976 {
977 if (empty($this->subsiteBlogId)) {
978 $this->subsiteBlogId = get_current_blog_id();
979 }
980
981 return (int)$this->subsiteBlogId;
982 }
983
984
985
986
987 public function getIsValidateBackupFiles(): bool
988 {
989 return (bool)$this->isValidateBackupFiles;
990 }
991
992
993
994
995
996 public function setIsValidateBackupFiles($isValidateBackupFiles)
997 {
998 $this->isValidateBackupFiles = (bool)$isValidateBackupFiles;
999 }
1000
1001
1002
1003
1004 public function getIsBackupFormatV1(): bool
1005 {
1006 return Hooks::applyFilters(BackupMetadata::FILTER_BACKUP_FORMAT_V1, false);
1007 }
1008
1009
1010
1011
1012 public function getIsContaining2GBFile(): bool
1013 {
1014 return $this->isContaining2GBFile;
1015 }
1016
1017
1018
1019
1020
1021 public function setIsContaining2GBFile(bool $isContaining2GBFile)
1022 {
1023 $this->isContaining2GBFile = $isContaining2GBFile;
1024 }
1025
1026 public function getIsGlitchInBackup(): bool
1027 {
1028 return $this->isGlitchInBackup;
1029 }
1030
1031
1032
1033
1034
1035 public function setIsGlitchInBackup(bool $isGlitchInBackup)
1036 {
1037 $this->isGlitchInBackup = $isGlitchInBackup;
1038 }
1039
1040 public function getGlitchReason(): string
1041 {
1042 return $this->glitchReason;
1043 }
1044
1045
1046
1047
1048
1049 public function setGlitchReason(string $glitchReason)
1050 {
1051 $this->glitchReason = $glitchReason;
1052 }
1053
1054
1055
1056
1057 public function getCurrentWrittenFileHeaderBytes(): int
1058 {
1059 return (int)$this->currentWrittenFileHeaderBytes;
1060 }
1061
1062
1063
1064
1065
1066 public function setCurrentWrittenFileHeaderBytes(int $currentWrittenFileHeaderBytes)
1067 {
1068 $this->currentWrittenFileHeaderBytes = (int)$currentWrittenFileHeaderBytes;
1069 }
1070
1071 public function getCurrentFileStartOffset(): int
1072 {
1073 return $this->currentFileStartOffset;
1074 }
1075
1076
1077
1078
1079
1080 public function setCurrentFileStartOffset(int $currentFileStartOffset)
1081 {
1082 $this->currentFileStartOffset = (int)$currentFileStartOffset;
1083 }
1084
1085
1086
1087
1088
1089 public function setFileAppendTimeLimit(int $timeLimit)
1090 {
1091 $this->fileAppendTimeLimit = $timeLimit;
1092 }
1093
1094
1095
1096
1097 public function getFileAppendTimeLimit(): int
1098 {
1099 return $this->fileAppendTimeLimit;
1100 }
1101
1102
1103
1104
1105 public function incrementFileAppendTimeLimit()
1106 {
1107 $this->fileAppendTimeLimit += 5;
1108 }
1109
1110
1111
1112
1113 public function resetFileAppendTimeLimit()
1114 {
1115 $this->fileAppendTimeLimit = 10;
1116 }
1117
1118
1119
1120
1121 public function getIsCompressed(): bool
1122 {
1123 return $this->isCompressed;
1124 }
1125
1126
1127
1128
1129
1130 public function setIsCompressed(bool $isCompressed)
1131 {
1132 $this->isCompressed = $isCompressed;
1133 }
1134
1135
1136
1137
1138 public function getBackupSizeUncompressed(): int
1139 {
1140 return $this->backupSizeUncompressed;
1141 }
1142
1143
1144
1145
1146
1147 public function setBackupSizeUncompressed(int $backupSizeUncompressed)
1148 {
1149 $this->backupSizeUncompressed = $backupSizeUncompressed;
1150 }
1151
1152
1153
1154
1155
1156 public function addBackupSizeUncompressed(int $backupSizeUncompressed)
1157 {
1158 $this->backupSizeUncompressed += $backupSizeUncompressed;
1159 }
1160
1161
1162
1163
1164 public function getBackupSizeCompressed(): int
1165 {
1166 return $this->backupSizeCompressed;
1167 }
1168
1169
1170
1171
1172
1173 public function setBackupSizeCompressed(int $backupSizeCompressed)
1174 {
1175 $this->backupSizeCompressed = $backupSizeCompressed;
1176 }
1177
1178
1179
1180
1181
1182 public function addBackupSizeCompressed(int $backupSizeCompressed)
1183 {
1184 $this->backupSizeCompressed += $backupSizeCompressed;
1185 }
1186
1187
1188
1189
1190 public function getTotalFilesCompressed(): int
1191 {
1192 return $this->totalFilesCompressed;
1193 }
1194
1195
1196
1197
1198
1199 public function setTotalFilesCompressed(int $totalFilesCompressed)
1200 {
1201 $this->totalFilesCompressed = $totalFilesCompressed;
1202 }
1203
1204
1205
1206
1207 public function incrementTotalFilesCompressed()
1208 {
1209 $this->totalFilesCompressed++;
1210 }
1211 }
1212