Overview
Comment: | Take advantage of VACUUM INTO and SQLite3::backup to create a backup |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk | stable |
Files: | files | file ages | folders |
SHA3-256: |
1e60143722832379879c92258ac0cd9b |
User & Date: | bohwaz on 2021-04-25 16:39:44 |
Other Links: | manifest | tags |
Context
2021-04-25
| ||
16:46 | Download archive from restore list check-in: c247073dfc user: bohwaz tags: trunk, stable | |
16:39 | Take advantage of VACUUM INTO and SQLite3::backup to create a backup check-in: 1e60143722 user: bohwaz tags: trunk, stable | |
16:06 | Fix restore from old versions check-in: 2a28bf369a user: bohwaz tags: trunk, stable | |
Changes
Modified src/include/lib/Garradin/Sauvegarde.php from [905d94c1da] to [b14c3f16f0].
︙ | ︙ | |||
102 103 104 105 106 107 108 | $this->make($backup); return basename($backup); } protected function make(string $dest) { | | < | < | > > | < | > > > | > > | | | > | 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 | $this->make($backup); return basename($backup); } protected function make(string $dest) { // Acquire lock $version = \SQLite3::version(); $db = DB::getInstance(); Utils::safe_unlink($dest); if ($version['versionNumber'] >= 3027000) { // use VACUUM INTO instead when SQLite 3.27+ is required $db->exec(sprintf('VACUUM INTO %s;', $db->quote($dest))); } else { // use ::backup since PHP 7.4.0+ // https://www.php.net/manual/en/sqlite3.backup.php $dest_db = new \SQLite3($dest); $db->backup($dest_db); $dest_db->exec('PRAGMA journal_mode = DELETE;'); $dest_db->exec('VACUUM;'); $db->close(); } } /** * Effectue une rotation des sauvegardes automatiques * association.auto.1.sqlite deviendra association.auto.2.sqlite par exemple */ public function rotate(): void |
︙ | ︙ |