# @ankitsolanki90/backupwrapper

> A very basic nodejs wrapper around the pg_dump and pg_restore

Latest version **0.0.4** (published 2022-07-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install @ankitsolanki90/backupwrapper
pnpm add @ankitsolanki90/backupwrapper
yarn add @ankitsolanki90/backupwrapper
bun add @ankitsolanki90/backupwrapper
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; large bundle; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.4 |
| Published | 2022-07-06 |
| First published | 2022-07-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 11.6 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Ankit Solanki |
| Maintainers | ankitsolanki90 |
| Keywords | pg, pg_dump, pg_restore, postgres |

## Links

- npm: https://www.npmjs.com/package/@ankitsolanki90/backupwrapper
- Repository: https://gitlab.digihealth.in/ankit/pg-dump-restore-node-wrapper
- Issues: https://gitlab.digihealth.in/ankit/pg-dump-restore-node-wrapper/-/issues
- npm.io page: https://npm.io/package/@ankitsolanki90/backupwrapper

## Dependencies (2)

- [path](https://npm.io/package/path.md) ^0.12.7
- [execa](https://npm.io/package/execa.md) ^4.0.0

## Recent versions

- 0.0.4 (latest) — 2022-07-06
- 0.0.3 — 2022-07-06

## README

# pg-dump-restore-node-wrapper

This very small utility that includes pg_dump and pg_restore binaries for Windows and macOS, taken from Postgres 13.4. DLLs and dylibs are also included, making the binaries standalone.

A thin CLI wrapper is also provided.

## Usage

```js
import pgDumpRestore from "pg-dump-restore-node-wrapper";

async function main() {
  const { stdout, stderr } = await pgDumpRestore.dump({
    port, // defaults to 5432
    host,
    dbname,
    username,
    password,
    file: "./test.pgdump",
    format, // defaults to 'c'
  }); // outputs an execa object

  const { stdout, stderr } = await pgDumpRestore.restore({
    port, // defaults to 5432
    host,
    dbname,
    username,
    password,
    filename: "./test.pgdump", // note the filename instead of file, following the pg_restore naming.
    clean, // defaults to false
    create, // defaults to false
  }); // outputs an execa object
}
```

Please see the [pg_dump](https://www.postgresql.org/docs/12/app-pgdump.html) and [pg_restore](https://www.postgresql.org/docs/12/app-pgrestore.html) documentation for details on the arguments and [execa](https://github.com/sindresorhus/execa) for details on the output streams.

### Creating the binaries

pg_dump V<=X can be restored using pg_restore V>=X.

I chose to use pg_dump and pg_restore for Postgres 13, as most of the machines I manage have Postgres 13, (and I only use Postgres 12 features).

### macOS

I used macdylibbundler from https://github.com/SCG82/macdylibbundler to list all dll files and I then copied and renamed them.

I did not use the tool to bundle the dependencies as it would corrupt the executable.

### Windows

I used https://github.com/lucasg/Dependencies to determine the required DLL, filtering only the local dependencies.

---
_Source: https://npm.io/package/@ankitsolanki90/backupwrapper · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
