1

I tried to generate postgresql dump file using Node JS. SO, I used secure-backup library to generate pg-dump file encrypted. I add this package in my project and I configured .pem file also. When I execute this file it's throwing some error. but I couldn't understand what type error is throwing and how to fix it I don't know. Any one give some suggestion how to resolve this issue to generate pg dump file using Node JS otherwise different library used to generate pg dump file.

CODE

let secureBackup = require('secure-backup');
let pgHandler = require('secure-backup/lib/handlers/pg')
console.log('hi')
let backup = secureBackup({
  pubKeyPath: 'C:/Users/DELL/Desktop/Twilio_Phone/cert.pem', // path to your public key
  outputPath: 'C:/Users/DELL/Desktop/DB_Dump', // where to output your encrypted backup
  compress: true, // enable compression (gzip)
  handler: pgHandler({
    user: 'postgres',
    password: '*****',
    database: '****'
  })
})
backup() // can be invoked directly
 
// or used with a cron-job module like node-schedule

Error

events.js:292
      throw er; // Unhandled 'error' event
      ^

Error: spawn pg_dump ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:269:19)
    at onErrorNT (internal/child_process.js:465:16)
    at processTicksAndRejections (internal/process/task_queues.js:80:21)
Emitted 'error' event on ChildProcess instance at:
    at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
    at onErrorNT (internal/child_process.js:465:16)
    at processTicksAndRejections (internal/process/task_queues.js:80:21) {
  errno: -4058,
  code: 'ENOENT',
  syscall: 'spawn pg_dump',
  path: 'pg_dump',
  spawnargs: [ '-U', 'postgres', 'HP', 'hummapi' ]
}
  • The pg_dump process exited with an error. However you can't see that error. Maybe try handling the error event and see if it contains useful information. – 404 Apr 29 '21 at 10:11

1 Answers1

1

Your output shows that pg_dump never ran - the first line of the error message says that the error occurred whilst spawning pg_dump. The error code ENOENT means Error, NO ENTity.

In other words, pg_dump could not be found. Presumably you have to either supply the library a path to the pg_dump executable, or make sure the directory containing that program is listed in the environment variable PATH.

Why not just call pg_dump directly?

Lee Goddard
  • 10,680
  • 4
  • 46
  • 63