npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@idirdev/dbsnap

v1.0.0

Published

Create and manage directory snapshots

Readme

dbsnap

[EN] Database snapshot utility for PostgreSQL and MySQL — create, list, restore, rotate and verify compressed/encrypted SQL dumps from the command line. [FR] Utilitaire de snapshots de base de données pour PostgreSQL et MySQL — créez, listez, restaurez, faites tourner et vérifiez des dumps SQL compressés/chiffrés depuis la ligne de commande.


Features / Fonctionnalités

[EN]

  • Creates SQL dumps via pg_dump (PostgreSQL) or mysqldump (MySQL)
  • Optional gzip compression (--compress) to shrink dump files
  • AES-256-GCM encryption (--encrypt) with password-derived key
  • SHA-256 checksum file generated automatically alongside every snapshot
  • verify command confirms snapshot integrity before restore
  • rotate command prunes old snapshots, keeping only the last N
  • Table output with name, size, date, compressed and encrypted flags
  • Reads DATABASE_URL env variable automatically

[FR]

  • Crée des dumps SQL via pg_dump (PostgreSQL) ou mysqldump (MySQL)
  • Compression gzip optionnelle (--compress) pour réduire les fichiers dump
  • Chiffrement AES-256-GCM (--encrypt) avec clé dérivée du mot de passe
  • Fichier de somme de contrôle SHA-256 généré automatiquement avec chaque snapshot
  • La commande verify confirme l'intégrité du snapshot avant la restauration
  • La commande rotate supprime les anciens snapshots en ne conservant que les N derniers
  • Sortie en tableau avec nom, taille, date, indicateurs de compression et de chiffrement
  • Lit automatiquement la variable d'environnement DATABASE_URL

Installation

npm install -g @idirdev/dbsnap

CLI Usage / Utilisation CLI

# Create a plain snapshot / Créer un snapshot simple
dbsnap create -c postgres://user:pass@localhost/mydb

# Compressed snapshot / Snapshot compressé
dbsnap create -c postgres://user:pass@localhost/mydb --compress -o ./backups

# Compressed + encrypted / Compressé + chiffré
dbsnap create -c postgres://user:pass@localhost/mydb --compress --encrypt "s3cr3tPwd" --name daily-backup

# List existing snapshots / Lister les snapshots existants
dbsnap list -d ./backups

# Restore from a snapshot / Restaurer depuis un snapshot
dbsnap restore ./backups/snapshot-2026-03-16.sql.gz -c postgres://user:pass@localhost/mydb

# Restore an encrypted snapshot / Restaurer un snapshot chiffré
dbsnap restore ./backups/daily-backup.sql.gz.enc -c postgres://... --password "s3cr3tPwd"

# Verify snapshot integrity / Vérifier l'intégrité d'un snapshot
dbsnap verify ./backups/snapshot-2026-03-16.sql.gz

# Keep only last 7 snapshots / Garder uniquement les 7 derniers snapshots
dbsnap rotate -d ./backups --keep 7

Example Output / Exemple de sortie

$ dbsnap list -d ./backups
┌──────────────────────────────────────┬────────┬────────────┬────────────┬───────────┐
│ Name                                 │ Size   │ Date       │ Compressed │ Encrypted │
├──────────────────────────────────────┼────────┼────────────┼────────────┼───────────┤
│ daily-backup.sql.gz.enc              │ 1.2MB  │ 2026-03-16 │ Yes        │ Yes       │
│ snapshot-2026-03-15T22-00-00-000Z.sql│ 4.8MB  │ 2026-03-15 │ No         │ No        │
└──────────────────────────────────────┴────────┴────────────┴────────────┴───────────┘

$ dbsnap verify ./backups/daily-backup.sql.gz.enc
Valid: a3f8c1d2e4b56789...

API (Programmatic) / API (Programmation)

const { createSnapshot, listSnapshots, restoreSnapshot, rotateSnapshots, verifySnapshot } = require('@idirdev/dbsnap');

// Create a snapshot / Créer un snapshot
const snap = await createSnapshot({
  connection: 'postgres://user:pass@localhost/mydb',
  output: './backups',
  compress: true,
  encrypt: 'myPassword',
  name: 'pre-deploy',
});
console.log(snap.file, snap.size, snap.checksum);

// List snapshots / Lister les snapshots
const list = listSnapshots('./backups');
list.forEach(s => console.log(s.name, s.size, s.date));

// Verify integrity / Vérifier l'intégrité
const check = verifySnapshot('./backups/pre-deploy.sql.gz.enc');
console.log(check.valid); // true

// Rotate, keep 5 / Rotation, garder 5
const removed = rotateSnapshots('./backups', 5);
console.log(removed + ' old snapshot(s) removed');

// Restore / Restaurer
await restoreSnapshot('./backups/pre-deploy.sql.gz.enc', {
  connection: 'postgres://user:pass@localhost/mydb',
  password: 'myPassword',
});

License

MIT — idirdev