// Online SQLite backup includes committed WAL transactions. Run in the service // container, then copy the resulting file to independent, protected storage. import { DatabaseSync, backup } from 'node:sqlite'; const source = process.env.SYNC_DB ?? './sync-data/pardis.sqlite'; const destination = process.argv[2]; if (!destination || destination === source) throw new Error('Usage: node server/backup.js /data/backup.sqlite (distinct destination)'); const db = new DatabaseSync(source, { readOnly: true }); try { await backup(db, destination); console.info('Encrypted database backup completed.'); } finally { db.close(); }