Added optionnal online storage and cross-client sync
This commit is contained in:
9
server/backup.js
Normal file
9
server/backup.js
Normal file
@@ -0,0 +1,9 @@
|
||||
// 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(); }
|
||||
Reference in New Issue
Block a user