Skip to content

Utility that gives ability to call pg_dump and pg_restore from nodejs.

Notifications You must be signed in to change notification settings

Kalvi-Education/pg-dump-restore

 
 

Repository files navigation

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
}

About

Utility that gives ability to call pg_dump and pg_restore from nodejs.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 98.5%
  • JavaScript 1.5%