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 🙏

© 2025 – Pkg Stats / Ryan Hefner

taara

v0.1.1

Published

Back up PostgreSQL tables to S3 or disk.

Downloads

7

Readme

taara

Build Status

A PostgreSQL table snapshot tool for node.js.

Installation

Install it using npm:

$ npm install taara

Or get it directly from: http://github.com/macobo/taara

Usage

To use the library, you need to configure to use storage engine. At this time, the library supports on-disk backups as well as S3 Backups.

Using S3 storage

var taara = require('taara');

var storageEngine = new taara.S3StorageEngine('my-bucket', s3AuthParams);
taara.useStorageEngine(storageEngine);

s3AuthParams - See AWS SDK documentation for available options which are passed to new AWS.S3(): http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Config.html#constructor-property

Using on-disk storage

var storageEngine = new taara.FileSystemEngine('/path/to/backup/location');
taara.useStorageEngine(storageEngine);

Storing a snapshot of a table.

var pgAuth = {
    host: "localhost",
    port: 5432,
    user: "postgres",
    database: "postgres",
    password: "my-password"
};

// Stored along with the snapshot, can be later used during the restore process
var userMetadata = { my: "value" };

taara.storeSnapshot('events', userMetadata, pgAuth).then(function(storageMetadata) {
    var identifier = storageMetadata.identifier;
    console.log("Stored snapshot of", identifier.tablenames, "at", identifier.date);
});

The snapshot will be stored at snapshot/events_20160112-235323.snapshot (depending on date) and snapshot at metadata/events_20160112-235323.metadata.

Listing snapshots and fetching stored metadata.

taara
    .listSnapshots()
    // Print out list of identifiers
    .tap(function(identifiers) {
        identifiers.forEach(function(identifier) {
            console.log("Snapshot of", identifier.tablenames, "was taken at", identifier.date);
        });
    })
    // And fetch metadata for one of the backups.
    .then(function(identifiers) {
        return taara.getMetadata(identifiers[0]));
    })
    .then(function(storageMetadata) {
        console.log("identifier:", storageMetadata.identifier);
        console.log("stats:", storageMetadata.stats);
        console.log("user-provided metadata:", storageMetadata.metadata);
    });

Restoring a snapshot

taara.restoreSnapshot(identifier, pgAuth)
    .then(function(storageMetadata) {
        console.log("Restored snapshot. identifier:", storageMetadata.identifier);
    });

API Documentation

Motivation

At Heap Analytics we use sharding, PostgreSQL and sharding extensively to store with our user data. As each shard is replicated, even if we lose a single database instance, we won't lose any data. However, if more databases than the replication factor should die, we'd need to deal with full-blown database restores simply to get at a few shards out of tens of thousands - something which is costly in terms of storage as well as time.

This library is an attempt to deal better with that problem - instead of making full-blown database backups, we store snapshots of tables on S3 with some Kafka metadata. Should shards "disappear" we can use the snapshot to restore the shards to a good state and replay all new events that that happened since using Kafka.

Contributing

To setup, you need to install a few dependencies:

  • npm install -g typescript gulp
  • npm install

To compile and to do a test run:

  • docker-compose up -d - starts a database and fake_s3 instance. [1]
  • gulp test

[1]: More on Docker Compose here.