Registry / database / sqlite-backup

sqlite-backup

JSON →
library0.2.1jsnpmunverified

SQLite backup helper for Expo and React Native. Current version 0.2.1. Provides SQLite database backup and restore functionality as an Expo module, integrating with expo-sqlite. Releases track Expo SDK versions; peer-dep requires expo ^51.0.32. Key differentiator: native backup/restore via expo modules, not pure JS. Supports managed Expo workflows and bare React Native. TypeScript types included.

npm install sqlite-backup
INSTALL
IMPORT
SIG · SQLITE-BACKUP
S
sqlite-backup
databasejavascriptv0.2.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

SqliteBackup
import * as SqliteBackup from 'sqlite-backup';
const SqliteBackup = require('sqlite-backup');
The module is ESM-only; CommonJS require may not work in all bundlers.
backupDatabaseAsync
import { backupDatabaseAsync } from 'sqlite-backup';
import { backupDatabaseAsync } from 'expo-sqlite-backup';
Function exported directly from the package.
restoreDatabaseAsync
import { restoreDatabaseAsync } from 'sqlite-backup';
import { restoreDatabaseAsync } from 'expo-sqlite-backup';
Ensure correct package name; mistaking the package name is common.
SqliteBackupOptions
import type { SqliteBackupOptions } from 'sqlite-backup';
import { SqliteBackupOptions } from 'sqlite-backup';
This is a TypeScript type, not runtime value; use import type.

Shows basic backup and restore operations using sqlite-backup with expo-sqlite.

import * as SQLite from 'expo-sqlite'; import * as SqliteBackup from 'sqlite-backup'; async function backupDatabase() { const dbName = 'myDatabase.db'; const backupName = 'myDatabase_backup.db'; try { await SqliteBackup.backupDatabaseAsync(dbName, backupName); console.log('Backup successful'); } catch (error) { console.error('Backup failed:', error); } } async function restoreDatabase() { const dbName = 'myDatabase.db'; const backupName = 'myDatabase_backup.db'; try { await SqliteBackup.restoreDatabaseAsync(dbName, backupName); console.log('Restore successful'); } catch (error) { console.error('Restore failed:', error); } } // Usage backupDatabase(); restoreDatabase();
Debug
Known issues
gotchaDoes not work with in-memory databases; only persistent SQLite databases.
fix
Ensure database is stored on disk when using backup/restore functions.
affects: >=0.0.0
breakingAPI changed from version 0.1.x to 0.2.0: backupDatabaseAsync and restoreDatabaseAsync now require database names, not database objects.
fix
Pass database name (string) as first argument instead of database object.
affects: >=0.2.0
deprecatedbackupDatabase and restoreDatabase (without Async suffix) are deprecated since 0.2.0.
fix
Use backupDatabaseAsync and restoreDatabaseAsync instead.
affects: >=0.2.0
gotchaDatabase backup directory may differ between iOS and Android; path resolution issues common.
fix
Always use absolute paths or rely on default directory returned by expo-file-system.
affects: >=0.0.0
Errors
Common errors & fixes
Cannot find module 'sqlite-backup' or its corresponding type declarations.
Missing npm install or unmet peer dependencies.
fix
Run 'npm install sqlite-backup expo-sqlite' and ensure Expo SDK >= 51.
TypeError: (0 , _sqliteBackup.backupDatabaseAsync) is not a function
Importing from wrong package or incorrect export name.
fix
Use 'import * as SqliteBackup from "sqlite-backup";' and call SqliteBackup.backupDatabaseAsync(...).
Error: backupDatabaseAsync is not available in managed workflow
Attempting to use backup on a platform that doesn't support native modules (e.g., web).
fix
Use Platform.OS to conditionally call backup/restore only on iOS/Android.
SqliteBackup.backupDatabaseAsync is not a function (In 'SqliteBackup.backupDatabaseAsync(dbName, backupName)', 'SqliteBackup.backupDatabaseAsync' is undefined)
Importing the module incorrectly (e.g., default import instead of namespace).
fix
Use 'import * as SqliteBackup from "sqlite-backup";' instead of default import.
Upgrade
Version history
0.2.1latest on npm
Audit
Dependencies
exporequiredPeer dependency required for Expo module runtime.
reactrequiredPeer dependency for React Native.
react-nativerequiredPeer dependency for React Native.
Agent activity
18 hits · last 30 days
node
14
Meta
2
OpenAI (training)
1
Resources
sqlite-backup — npm install sqlite-backup · libregistry