PluginProbe ʕ •ᴥ•ʔ
JetBackup – Backup, Restore & Migrate / 3.1.18.8
JetBackup – Backup, Restore & Migrate v3.1.18.8
3.1.22.3 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 1.4.8.1 1.4.9 1.5.0 1.5.1 1.5.1.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.6.0 1.6.10 1.6.11 1.6.12 1.6.13 1.6.15 1.6.5.1 1.6.8.8 1.6.9 1.6.9.1 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7.5 2.0.8.7 2.0.9.11 2.0.9.14 2.0.9.15 2.0.9.6 2.0.9.7 2.0.9.9 3.1.10.7 3.1.11.1 3.1.12.3 3.1.13.4 3.1.14.17 3.1.15.4 3.1.16.1 3.1.17.5 3.1.18.10 3.1.18.8 3.1.18.9 3.1.19.8 3.1.20.3 3.1.21.3 3.1.7.9 3.1.9.2 trunk 1.1.90 1.1.91 1.2.0 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 1.4.2
backup / src / JetBackup / Settings / Performance.php
backup / src / JetBackup / Settings Last commit date
.htaccess 5 months ago Automation.php 5 months ago General.php 5 months ago Integrations.php 5 months ago Logging.php 5 months ago Maintenance.php 5 months ago Notifications.php 5 months ago Performance.php 5 months ago Restore.php 5 months ago Security.php 5 months ago Settings.php 5 months ago Updates.php 5 months ago index.html 5 months ago web.config 5 months ago
Performance.php
186 lines
1 <?php
2
3 namespace JetBackup\Settings;
4
5 use JetBackup\BackupJob\BackupJob;
6 use JetBackup\Config\System;
7 use JetBackup\Exception\FieldsValidationException;
8 use JetBackup\Exception\IOException;
9 use ReflectionException;
10
11 if (!defined( '__JETBACKUP__')) die('Direct access is not allowed');
12
13 class Performance extends Settings {
14
15 const SECTION = 'performance';
16
17 const EXECUTION_TIME = 'PERFORMANCE_EXECUTION_TIME';
18
19 const READ_CHUNK_SIZE = 'READ_CHUNK_SIZE';
20 const SQL_CLEANUP_REVISIONS = 'SQL_CLEANUP_REVISIONS';
21 const USE_DEFAULT_EXCLUDES = 'USE_DEFAULT_EXCLUDES';
22 const EXCLUDE_NESTED_SITES = 'EXCLUDE_NESTED_SITES';
23
24 const USE_DEFAULT_DB_EXCLUDES = 'USE_DEFAULT_DB_EXCLUDES';
25 const GZIP_COMPRESS_ARCHIVE = 'GZIP_COMPRESS_ARCHIVE';
26 const GZIP_COMPRESS_DB = 'GZIP_COMPRESS_DB';
27 const DEFAULT_EXCLUDES = 'DEFAULT_EXCLUDES';
28 const DEFAULT_DB_EXCLUDES = 'DEFAULT_DB_EXCLUDES';
29 const EXECUTION_TIMES = [0, 10, 20, 30, 40, 50, 60, 120, 300, 600];
30
31 /**
32 * @throws IOException
33 * @throws ReflectionException
34 */
35 public function __construct() {
36 parent::__construct(self::SECTION);
37 }
38
39 /**
40 * @return int
41 */
42 public function getExecutionTime():int { return (int) $this->get(self::EXECUTION_TIME, 0); }
43
44 /**
45 * @param int $value
46 *
47 * @return void
48 */
49 public function setExecutionTime(int $value):void { $this->set(self::EXECUTION_TIME, $value); }
50
51 /**
52 *
53 * @return int
54 */
55 public function getReadChunkSize():int { return (int) $this->get(self::READ_CHUNK_SIZE, 1); } // used for GUI only
56
57 public function getReadChunkSizeBytes():int { return $this->getReadChunkSize() * 1024 * 1024; }
58
59 /**
60 * @param int $value
61 *
62 * @return void
63 */
64 public function setReadChunkSize(int $value):void { $this->set(self::READ_CHUNK_SIZE, $value); }
65
66 /**
67 * @return bool
68 */
69 public function isSQLCleanupRevisionsEnabled():bool { return (bool) $this->get(self::SQL_CLEANUP_REVISIONS, false); }
70
71 /**
72 * @param bool $value
73 *
74 * @return void
75 */
76 public function setSQLCleanupRevisionsEnabled(bool $value):void { $this->set(self::SQL_CLEANUP_REVISIONS, $value); }
77
78 /**
79 * @return bool
80 */
81 public function isUseDefaultExcludes():bool { return (bool) $this->get(self::USE_DEFAULT_EXCLUDES, true); }
82
83 /**
84 * @param bool $value
85 *
86 * @return void
87 */
88 public function setUseDefaultExcludes(bool $value):void { $this->set(self::USE_DEFAULT_EXCLUDES, $value); }
89
90 /**
91 * @return bool
92 */
93 public function isExcludeNestedSitesEnabled():bool { return (bool) $this->get(self::EXCLUDE_NESTED_SITES, true); }
94
95 /**
96 * @param bool $value
97 *
98 * @return void
99 */
100 public function setExcludeNestedSites(bool $value):void { $this->set(self::EXCLUDE_NESTED_SITES, $value); }
101
102 /**
103 * @return bool
104 */
105 public function isUseDefaultDBExcludes():bool { return (bool) $this->get(self::USE_DEFAULT_DB_EXCLUDES, true); }
106
107 /**
108 * @param bool $value
109 *
110 * @return void
111 */
112 public function setUseDefaultDBExcludes(bool $value):void { $this->set(self::USE_DEFAULT_DB_EXCLUDES, $value); }
113
114 /**
115 * @return bool
116 */
117 public function isGzipCompressArchive():bool { return (bool) $this->get(self::GZIP_COMPRESS_ARCHIVE, true); }
118
119 /**
120 * @param bool $value
121 *
122 * @return void
123 */
124 public function setGzipCompressArchive(bool $value):void { $this->set(self::GZIP_COMPRESS_ARCHIVE, $value); }
125
126 /**
127 * @return bool
128 */
129 public function isGzipCompressDB():bool { return (bool) $this->get(self::GZIP_COMPRESS_DB, true); }
130
131 /**
132 * @param bool $value
133 *
134 * @return void
135 */
136 public function setGzipCompressDB(bool $value):void { $this->set(self::GZIP_COMPRESS_DB, $value); }
137
138 /**
139 * @return array
140 */
141 public function getDisplay():array {
142
143 return [
144 self::READ_CHUNK_SIZE => $this->getReadChunkSize(),
145 self::EXECUTION_TIME => $this->getExecutionTime(),
146 self::SQL_CLEANUP_REVISIONS => $this->isSQLCleanupRevisionsEnabled() ? 1 : 0,
147 self::USE_DEFAULT_EXCLUDES => $this->isUseDefaultExcludes() ? 1 : 0,
148 self::EXCLUDE_NESTED_SITES => $this->isExcludeNestedSitesEnabled() ? 1 : 0,
149 self::USE_DEFAULT_DB_EXCLUDES => $this->isUseDefaultDBExcludes() ? 1 : 0,
150 self::GZIP_COMPRESS_ARCHIVE => $this->isGzipCompressArchive() ? 1 : 0,
151 self::GZIP_COMPRESS_DB => $this->isGzipCompressDB() ? 1 : 0,
152 self::DEFAULT_EXCLUDES => BackupJob::getDefaultExcludes(null, null),
153 self::DEFAULT_DB_EXCLUDES => BackupJob::DEFAULT_DATABASE_EXCLUDES,
154 ];
155 }
156
157 /**
158 * @return array
159 */
160 public function getDisplayCLI():array {
161
162 return [
163 'Read Chunk Size' => $this->getReadChunkSize(),
164 'Max Execution Time' => $this->getExecutionTime(),
165 'SQL Cleanup Revisions' => $this->isSQLCleanupRevisionsEnabled() ? "Yes" : "No",
166 'Use Default Excludes' => $this->isUseDefaultExcludes() ? "Yes" : "No",
167 'Exclude Nested Sites' => $this->isExcludeNestedSitesEnabled() ? "Yes" : "No",
168 'Use Default Database Excludes' => $this->isUseDefaultDBExcludes() ? "Yes" : "No",
169 'Compress Backup Files' => $this->isGzipCompressArchive() ? "Yes" : "No",
170 'Compress Backup Database' => $this->isGzipCompressDB() ? "Yes" : "No",
171 ];
172 }
173
174 /**
175 * @throws FieldsValidationException
176 */
177 public function validateFields():void {
178
179 if(!in_array($this->getExecutionTime(), self::EXECUTION_TIMES))
180 throw new FieldsValidationException('Execution time of '. $this->getExecutionTime() . ' is not allowed');
181
182 $serverExecutionTime = System::getServerExecutionTime();
183 if ($serverExecutionTime > 0 && $this->getExecutionTime() > $serverExecutionTime)
184 throw new FieldsValidationException( 'Execution time of ' . $this->getExecutionTime() . ' seconds cannot be higher than server defaults: ' . $serverExecutionTime);
185 }
186 }