Derek Anderson 456334aca0
Fix security scan and permissions issues in CI workflow
- Update CodeQL Action from deprecated v2 to v3
- Add proper permissions for security-events:write
- Add contents:write permission for version update job
- Fix GitHub Security tab integration issues
2025-06-26 20:28:56 -05:00
2025-06-26 20:03:26 -05:00
2025-06-26 20:03:26 -05:00
2025-06-26 20:03:26 -05:00
2025-06-26 20:03:26 -05:00
2025-06-26 20:03:26 -05:00
2025-06-26 20:15:40 -05:00
2025-06-26 20:03:26 -05:00
2025-06-26 20:15:40 -05:00
2025-06-26 20:10:16 -05:00
2025-06-26 20:10:21 -05:00

npm version npm downloads npm license Node.js supported SQLite Zero Dependencies

SQLite Backup Library

A standalone, zero-dependency Node.js library for creating, managing, and verifying SQLite database backups. Perfect for automated backup systems, cron jobs, and database maintenance scripts.

Features

  • 🚀 Multiple backup methods: SQLite backup command, file copy, and vacuum
  • Backup verification: Automatic integrity checking using SQLite's built-in PRAGMA
  • 🧹 Automated cleanup: Remove old backups based on retention policies
  • 📋 Backup management: List, verify, and restore backups
  • 🔐 Checksum calculation: SHA-256 checksums for backup verification
  • 📊 Detailed reporting: File sizes, durations, and comprehensive status reporting
  • 🛠️ CLI tool: Command-line interface for easy scripting and automation
  • 📦 Zero dependencies: Pure Node.js with no external dependencies

Installation

npm install sqlite-snap

Or install globally for CLI usage:

npm install -g sqlite-snap

Quick Start

Programmatic Usage

const { SQLiteBackup, BackupUtils } = require('sqlite-snap');

// Initialize backup instance
const backup = new SQLiteBackup({
    databasePath: './data/app.db',
    backupDirectory: './backups'
});

// Create a backup
const result = await backup.createBackup({
    includeTimestamp: true,
    verifyIntegrity: true,
    method: 'backup'
});

if (result.success) {
    console.log(`Backup created: ${result.backupPath}`);
    console.log(`Size: ${BackupUtils.formatSize(result.size)}`);
} else {
    console.error(`Backup failed: ${result.error}`);
}

CLI Usage

# Create a backup
sqlite-backup create ./data/app.db

# Create backup with custom options
sqlite-backup create ./data/app.db --backup-dir ./custom-backups --method copy

# List all backups
sqlite-backup list ./data/app.db --include-checksums

# Clean up old backups (keep last 30 days)
sqlite-backup cleanup ./data/app.db --retention-days 30

# Restore a backup
sqlite-backup restore ./backups/backup.db ./data/app.db

# Verify backup integrity
sqlite-backup verify ./backups/backup.db

API Reference

SQLiteBackup Class

Constructor

const backup = new SQLiteBackup(options)

Options:

  • databasePath (string, required): Path to the SQLite database file
  • backupDirectory (string, optional): Directory to store backups (default: <database-dir>/backups)
  • createBackupDir (boolean, optional): Create backup directory if it doesn't exist (default: true)

Methods

createBackup(options)

Creates a backup of the SQLite database.

const result = await backup.createBackup({
    filename: 'custom-backup.db',        // Custom filename (optional)
    includeTimestamp: true,              // Include timestamp in filename
    verifyIntegrity: true,               // Verify backup after creation
    method: 'backup'                     // Backup method: 'backup', 'copy', 'vacuum'
});

Returns: Promise

Description
effortlessly backup you're sqlite db with best practices.
Readme 70 KiB
2026-02-05 03:55:02 -07:00
Languages
JavaScript 100%