|
7 | 7 | use DateTimeImmutable; |
8 | 8 | use InvalidArgumentException; |
9 | 9 | use PDO; |
| 10 | +use SQLite3; |
10 | 11 |
|
11 | 12 | final class RedmineInstance |
12 | 13 | { |
@@ -190,25 +191,53 @@ private function runDatabaseMigration() |
190 | 191 | */ |
191 | 192 | private function createDatabaseBackup() |
192 | 193 | { |
193 | | - copy($this->rootPath . $this->workingDB, $this->rootPath . $this->backupDB); |
| 194 | + $workingDB = new SQLite3($this->rootPath . $this->workingDB); |
| 195 | + |
| 196 | + $backupDB = new SQLite3($this->rootPath . $this->backupDB); |
| 197 | + |
| 198 | + $workingDB->backup($backupDB); |
| 199 | + |
| 200 | + $workingDB->close(); |
| 201 | + $backupDB->close(); |
194 | 202 | } |
195 | 203 |
|
196 | 204 | /** |
197 | 205 | * Create backup of migrated database |
198 | 206 | */ |
199 | 207 | private function saveMigratedDatabase() |
200 | 208 | { |
201 | | - copy($this->rootPath . $this->workingDB, $this->rootPath . $this->migratedDB); |
| 209 | + $workingDB = new SQLite3($this->rootPath . $this->workingDB); |
| 210 | + |
| 211 | + $migratedDB = new SQLite3($this->rootPath . $this->migratedDB); |
| 212 | + |
| 213 | + $workingDB->backup($migratedDB); |
| 214 | + |
| 215 | + $workingDB->close(); |
| 216 | + $migratedDB->close(); |
202 | 217 | } |
203 | 218 |
|
204 | 219 | private function restoreFromMigratedDatabase(): void |
205 | 220 | { |
206 | | - copy($this->rootPath . $this->migratedDB, $this->rootPath . $this->workingDB); |
| 221 | + $workingDB = new SQLite3($this->rootPath . $this->workingDB); |
| 222 | + |
| 223 | + $migratedDB = new SQLite3($this->rootPath . $this->migratedDB); |
| 224 | + |
| 225 | + $migratedDB->backup($workingDB); |
| 226 | + |
| 227 | + $workingDB->close(); |
| 228 | + $migratedDB->close(); |
207 | 229 | } |
208 | 230 |
|
209 | 231 | private function restoreDatabaseFromBackup(): void |
210 | 232 | { |
211 | | - copy($this->rootPath . $this->backupDB, $this->rootPath . $this->workingDB); |
| 233 | + $workingDB = new SQLite3($this->rootPath . $this->workingDB); |
| 234 | + |
| 235 | + $backupDB = new SQLite3($this->rootPath . $this->backupDB); |
| 236 | + |
| 237 | + $backupDB->backup($workingDB); |
| 238 | + |
| 239 | + $workingDB->close(); |
| 240 | + $backupDB->close(); |
212 | 241 | } |
213 | 242 |
|
214 | 243 | private function removeDatabaseBackups(): void |
|
0 commit comments