Initial I Want to Heal app

This commit is contained in:
Warren H
2026-06-17 20:04:36 -04:00
parent 3880db1b58
commit 3c90998a61
109 changed files with 32775 additions and 0 deletions
+20
View File
@@ -0,0 +1,20 @@
import { mkdirSync } from 'node:fs'
import { resolve } from 'node:path'
import { DatabaseSync } from 'node:sqlite'
const sourcePath = resolve('data/game.db')
const backupDirectory = resolve('backups')
const timestamp = new Date().toISOString().replaceAll(':', '-').replaceAll('.', '-')
const backupPath = resolve(backupDirectory, `game-${timestamp}.db`)
mkdirSync(backupDirectory, { recursive: true })
const database = new DatabaseSync(sourcePath)
try {
const escapedPath = backupPath.replaceAll("'", "''")
database.exec(`VACUUM INTO '${escapedPath}'`)
console.log(`SQLite backup created: ${backupPath}`)
} finally {
database.close()
}