In the event of a catastrophic failure, it’s important to have a recent backup of your data. However, if you only need to restore the structure of your database, you can use a backup schema-only.
Creating a backup schema-only is easy. Just use the pg_backup command with the -S switch:
pg_backup -S mydatabase
This will create a backup of your database in the mydatabase directory.
To restore your database, just use the pg_restore command:
pg_restore -d mydatabase mydatabase.backup
This will …