Options
All
  • Public
  • Public/Protected
  • All
Menu

heroback (v3.0.2)

heroback

An agnostic database backup tool fully implemented using Streams.

Getting started

# Add to your dependencies using yarn
yarn global add "nxtep-io/heroback#master";

# Or, using NPM
npm install --global "github:nxtep-io/heroback#master";

Then, just call it from the command line.

# Minimal configuration takes only the database connection URL
heroback dump "<url>"

Available providers

Heroback will try to understand the supplied connection URI to use one of the available providers in the library and dump its content to a file.

  • PostgreSQL:
# Dumps to local file
heroback dump postgresql://localhost/test

# Restores from local file
heroback restore "20181118.052834.298000000.dump.sql" "postgresql://localhost/test";

  • MySQL / MariaDB:
# Dumps to local file
heroback dump mysql://localhost/test

# Restores from local file
heroback restore "20181118.052834.298000000.dump.sql" "mysql://localhost/test";

  • MongoDB:
# Dumps to local file
heroback dump mongo://localhost/test

# Restores from local file
heroback restore "20181118.052834.298000000.dump.archive" "mongo://localhost/test";

Available importers / exporters

Heroback will try to understand the supplied connection URI to use one of the available providers in the library and dump its content to a file.

  • File (Default): Streams the dump to/from a local file.

  • Amazon S3: Streams the dump output to a S3 bucket in AWS. Checkout the sample script.

    This exporter depeneds on the aws-sdk module and its environment variables.

  • Google GCS: Streams the dump output to a Google Cloud Storage. Checkout the sample script.

    This exporter depeneds on the @google-cloud/storage module and its environment variables.


Coming soon: Elasticsearch.

Programmatic Usage

You can use Heroback under the hood in your NodeJS / Typescript projects.

import Heroback from 'heroback';

// Prepare a new heroback instance
const heroback = new Heroback();

// Prepares to dump database to a local file
const dump = await heroback.dump({
  exporter: 'file',
  uri: 'postgres://locahost/test',
});

// Start the streaming to the local file
await dump.export();
console.log('Exported successfully!');

Check the samples/ directory in the repository.


License

The project is licensed under the MIT License.

Generated using TypeDoc