initial version
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
import Database from 'better-sqlite3';
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import { execSync } from 'node:child_process';
|
||||
|
||||
const backupDir = process.env.BACKUP_DIR || '/backups';
|
||||
const date = execSync('date +%F').toString().trim();
|
||||
|
||||
fs.mkdirSync(backupDir, { recursive: true });
|
||||
|
||||
const db = new Database(path.join(process.cwd(), 'data', 'app.db'));
|
||||
await db.backup(path.join(backupDir, `app-${date}.db`));
|
||||
db.close();
|
||||
|
||||
console.log(`Backed up to ${path.join(backupDir, `app-${date}.db`)}`);
|
||||
Reference in New Issue
Block a user