You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

pg-dump-restore

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pg-dump-restore

Nodejs wrapper around the pg_dump and pg_restore

1.0.13
latest
Source
npmnpm
Version published
Weekly downloads
2.8K
18.49%
Maintainers
1
Weekly downloads
 
Created
Source

pg-dump-restore

Utility that gives the 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
}

Keywords

pg

FAQs

Package last updated on 26 Jun 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts