I have tried to find a way to backup my database design without including the data stored in the database. Actually, one might say that I want to have a file that holds all "CREATE Scripts" in the database. Ideally, this file could be used to recreate the database (with no data of course).
How to avoid data in a database backup?
I am using pgAdmin 4.1.3 and PostgreSQL 9.6.
To back up, a PostgreSQL database, start by logging into your database server, then switch to the Postgres user account, and run pg_dump as follows (replace tecmintdb with the name of the database you want to backup). By default, the output format is a plain-text SQL script file.
There are three fundamentally different approaches to backing up PostgreSQL data: SQL dump. File system level backup. Continuous archiving.
Run the db_backup command to back up an entire database, or just a schema. In addition to restoring data by using the db_restore command, you can use the web console for data restore. Run the db_restore command to restore a database, a schema, or a table that was backed up using the db_backup command.
You can backup a single table, a schema, or a complete database. Select the name of the backup source in the pgAdmin tree control, right click to open the context menu, and select Backup… to open the Backup dialog. The name of the object selected will appear in the dialog title bar.
You can use this from psql(terminal):
pg_dump -s databasename > file.dump
from pg_dump documentation the "-s" dump only the object definitions (schema), not data.
pg_dump documentation
pg_dump --host localhost --port 5432 --username "userName" --schema-only --verbose --file "file path" "db_dev_local"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With