Skip to main content
added 544 characters in body
Source Link

Try below example, omitting the '-c' flag in pg_dump command:

pg_dump -C database_name | xz > backup-$(date -u +%Y-%m-%d).sql.xz

Answering comments (not sure if this is the best way to do it):

can you explain what that does exactly?

Performs a dump of the database and compress it to a file named with the current date

OP didn't have a -c or -C flag, and it was a custom format dump. I don't see how your answer contributes anything useful.

Well my answer tries to provide a solution to the post title, which is: Dump PostgreSQL without DROP DATABASE. If there are additional requirement to OP question, worth editing the post title.

Try below example, omitting the '-c' flag in pg_dump command:

pg_dump -C database_name | xz > backup-$(date -u +%Y-%m-%d).sql.xz

Try below example, omitting the '-c' flag in pg_dump command:

pg_dump -C database_name | xz > backup-$(date -u +%Y-%m-%d).sql.xz

Answering comments (not sure if this is the best way to do it):

can you explain what that does exactly?

Performs a dump of the database and compress it to a file named with the current date

OP didn't have a -c or -C flag, and it was a custom format dump. I don't see how your answer contributes anything useful.

Well my answer tries to provide a solution to the post title, which is: Dump PostgreSQL without DROP DATABASE. If there are additional requirement to OP question, worth editing the post title.

Source Link

Try below example, omitting the '-c' flag in pg_dump command:

pg_dump -C database_name | xz > backup-$(date -u +%Y-%m-%d).sql.xz