1.0.12 • Published 3 months ago

pg-dump-restore v1.0.12

Weekly downloads
-
License
ISC
Repository
github
Last release
3 months ago

pg-dump-restore

Utility that gives ability to call pg_dump and pg_restore from nodejs with all parameters. Please see the pg_dump and pg_restore documentation for details on the arguments. execa for details on the output streams.

Usage

import { pgDump, pgRestore } from "pg-dump-restore";

async function main() {
  const { stdout, stderr } = await pgDump(
    {
      port, // defaults to 5432
      host,
      database,
      username,
      password,
    },
    {
      file: "./dump.sql",
      format, // defaults to 'custom'
    },
  ); // outputs an execa object
}
import { pgDump, pgRestore } from "pg-dump-restore";

async function main() {
  const { stdout, stderr } = await pgRestore(
    {
      port, // defaults to 5432
      host,
      database,
      username,
      password,
    },
    {
      filename: "./dump.sql", // note the filename instead of file, following the pg_restore naming.
      clean, // defaults to false
      create, // defaults to false
    }
  ); // outputs an execa object
}

Command excludeTableDataPattern

The excludeTableDataPattern command allows excluding data from one or more tables during an operation. It can receive an array of names or patterns to specify the tables to be excluded. This option is useful when you only need the definition of a particular table but do not require the data it contains.

import { pgDump, pgRestore } from "pg-dump-restore";

async function main() {
  const { stdout, stderr } = await pgDump(
    {
      port, // defaults to 5432
      host,
      database,
      username,
      password,
    },
    {
      file: "./dump.sql",
      format, // defaults to 'custom'
      excludeTableDataPattern: ["table1", "table2"]
    },
  ); // outputs an execa object
}
1.0.12

3 months ago

1.0.9

6 months ago

1.0.8

7 months ago

1.0.7

7 months ago

1.0.11

6 months ago

1.0.10

6 months ago

1.0.6

10 months ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.2

2 years ago

1.0.3

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago