HiveBrain v1.2.0
Get Started
← Back to all entries
snippetsqlMinor

How to take backup of schema postgresql?

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
postgresqltakehowschemabackup

Problem

Hi I am currently using postgresql and deleting some of the tables for testing purpose and I want to take backup of schema. can any one let me know how to do that ?

Solution

You export only schema without data using pg_dump in psql [terminal]:

pg_dump -U postgres -s databasename > backup.sql


or with Pgadmin4

  • Go to Tool -> Backup and select only schema in the Dump option.

Code Snippets

pg_dump -U postgres -s databasename > backup.sql

Context

StackExchange Database Administrators Q#271130, answer score: 5

Revisions (0)

No revisions yet.