13 lines
408 B
JavaScript
13 lines
408 B
JavaScript
import fs from "fs";
|
|
import path from "path";
|
|
/**
|
|
* # Write a consistent copy of the database to `dst`
|
|
* @description Uses `VACUUM INTO`, which includes changes still in the WAL
|
|
* file (a plain file copy misses them).
|
|
*/
|
|
export default function snapshotDb({ db, dst }) {
|
|
fs.mkdirSync(path.dirname(dst), { recursive: true });
|
|
fs.rmSync(dst, { force: true });
|
|
db.run("VACUUM INTO ?", [dst]);
|
|
}
|