Backup Postgresql database using pg_dump?

Hi, I want to backup my database before editing the data. is it possible to backup my Postgresql database using pg_dump?

1 Like

This worked for me.

PGPASSWORD=<YOUR_DB_PASS> pg_dump \
  -h postgres.render.com \
  -U <YOUR_DB_USER> \
  --format=custom --no-acl --no-owner \
  <YOUR_DB_NAME> > <YOUR_DUMP_NAME>.dump
2 Likes

Thank you.

@stefan.luptak I got this error. Do you have any idea? Thank you in advance.

pg_dump: error: query failed: server closed the connection unexpectedly
	This probably means the server terminated abnormally
	before or while processing the request.
pg_dump: error: query was: SELECT amopstrategy, false AS amopreqcheck, amopopr::pg_catalog.regoperator, opfname AS sortfamily, nspname AS sortfamilynsp FROM pg_catalog.pg_amop ao JOIN pg_catalog.pg_depend ON (classid = 'pg_catalog.pg_amop'::pg_catalog.regclass AND objid = ao.oid) LEFT JOIN pg_catalog.pg_opfamily f ON f.oid = amopsortfamily LEFT JOIN pg_catalog.pg_namespace n ON n.oid = opfnamespace WHERE refclassid = 'pg_catalog.pg_opfamily'::pg_catalog.regclass AND refobjid = '20431'::pg_catalog.oid AND amopfamily = '20431'::pg_catalog.oid ORDER BY amopstrategy

The error has gone when I tried again. Thank you