From 7ffdb2eb80e2692355a1e01c1de6b1e52a0a3aa0 Mon Sep 17 00:00:00 2001 From: LouisLam Date: Thu, 19 Aug 2021 17:49:19 +0800 Subject: [PATCH] also backup sqlite shm, val file --- server/database.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/server/database.js b/server/database.js index 940f535c..d5eea619 100644 --- a/server/database.js +++ b/server/database.js @@ -69,6 +69,16 @@ class Database { const backupPath = "./data/kuma.db.bak" + version; fs.copyFileSync(Database.path, backupPath); + const shmPath = Database.path + "-shm"; + if (fs.existsSync(shmPath)) { + fs.copyFileSync(shmPath, shmPath + ".bak" + version); + } + + const walPath = Database.path + "-wal"; + if (fs.existsSync(walPath)) { + fs.copyFileSync(walPath, walPath + ".bak" + version); + } + // Try catch anything here, if gone wrong, restore the backup try { for (let i = version + 1; i <= this.latestVersion; i++) {