ConstThe database to backup from.
The path where the backup will be created.
Optionaloptions: BackupOptionsOptional configuration for the backup operation.
A promise that resolves when the backup is completed.
import { DatabaseSync, backup } from '@photostructure/sqlite';
const db = new DatabaseSync('./source.db');
await backup(db, './backup.db');
// With options
await backup(db, './backup.db', {
rate: 10,
progress: ({ totalPages, remainingPages }) => {
console.log(`Progress: ${totalPages - remainingPages}/${totalPages}`);
}
});
Standalone function to make a backup of a database.
This function matches the Node.js
node:sqlitemodule API which exportsbackup()as a standalone function in addition to thedb.backup()method.