mohan
mohan

Reputation: 381

How to take a dump of a Postgres DB using node js and upload the dump file in s3

Is there any a way to dump a Postgres DB using Node JS? How can I upload the dump file into AWS s3 bucket?

Upvotes: 0

Views: 3178

Answers (1)

Vao Tsun
Vao Tsun

Reputation: 51609

You can run bunch of COPY (...) to stdout commands with pg saving the result to the file. Then you can use aws sdk to put generated files to a bucket.

Apart of it is possible, I suggest you to try using pg_dump for backup and aws cli for moving it to bucket instead. It can be done with bash one-liner, smth like:

pg_dump -d dbname >db.dmp && aws s3 copy db.dmp s3://bucket_name/file_name

Upvotes: 1

Related Questions