Files
pardis/server/backup.js
Adrien W. 5686ee5072
All checks were successful
Tests et déploiement / validate (push) Successful in 2m44s
Tests et déploiement / deploy (push) Successful in 51s
Added optionnal online storage and cross-client sync
2026-10-10 16:01:06 +02:00

10 lines
624 B
JavaScript

// 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(); }