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

pg-backup

v0.0.2

Published

a small tool for backing up databases to backblaze b2

Readme

pg-backup

npm tests dependencies coverage

a small tool for backing up postgres databases to backblaze b2

Note: This project is in early development, and versioning is a little different. Read this for more details.

Why should you care?

Are you running a database on a linux box? What if that box suddenly is destroyed? Back up your databases so that in the event of a catastrophe, all is well. Backblaze B2 is the lowest cost long term storage backup service on the market, and the first 10gb are free, so you will pay little-to-nothing for your peace of mind.

Installation

npm install pg-backup -g

Note: Postgresql must also be installed in order for pg-backup to work

Usage

This project exposes a command line interface and a javascript API. We'll cover the use of both below.

CLI

In order to use the CLI, you first must configure it with your backblaze b2 API keys. To do this, run:

$ pg-backup --account-id xxx --application-key xxx --bucket-id xxx

You can get the account id and application key from the b2 dashboard. You'll also need to create a new bucket for your database backups. Once the bucket has been created, it will show you the bucket id.

find your b2 credentials

You can change your configuration details at any time. Once you have successfully authenticated, you can start backing up your databases. Test it out by backing up a database one time, manually, as such:

$ pg-backup --dbname database-name

If you'd like to have the database backed up at regular intervals, you can use the --schedule option. For example:

$ pg-backup --dbname database-name --schedule daily

You can have databases backed up hourly, daily, weekly, and monthly. Note that pg-backup will simply create a cron script to run these backups, so you must have crontab active and working in order to use the schedule option.

Javascript API

If you wish to use pg-backup through node.js, it exports a class that can be used to easily control your backups. First, you need to initialize the class with your backblaze credentials, as such:

const PgBackup = require('pg-backup')

const backup = new PgBackup({
  accountId: 'xxx',
  applicationKey: 'xxx',
  bucketId: 'xxx'
})

Now you can quickly back up a single database with the run instance method, which returns a promise:

backup.run({ name: 'database-name' })
  .then(console.log)

There are no scheduling options currently available in the javascript API. If you want long-running consistent backups, the CLI is recommended.

Running Tests

Since we depend on B2 in order for this to work, you need a B2 account in order to run the tests. In order to add your b2 account details, run cp test/.env.sample test/.env, then fill in test/.env with your account details. Make sure that you make a new bucket for testing specifically.

License & Contributing