If the target database already exists, consider dropping it and recreating it before starting the restore.
To export...
pg_dump -U username dbname > outputfile.sql
To export schema only (no data)...
pg_dump -s myschema > myschema.sqlÂ
To do this from a remote machine...
pg_dump -s -h myhost -U myuser -C myschema > myschema.sql
To backup all databases...
pg_dumpall -h myhost -U postgres -W > outputfile.sql
To backup all tables that start with "AO_8542F1"
pg_dump -h myhost -U atljira -W -t "\"AO_8542F1\"*" -f AO_8542F1.sql jira
In Jira, tables starting with AO_8542F1 relate to the Assets (previosuly Mindville Insight) functionality.Note that the escaped quotes \" ensure that the text is not "folded" to lower case. The * is a wildcard.See: https://www.postgresql.org/docs/current/app-psql.html#APP-PSQL-PATTERNS for more information.To restore from a 'plain' text file...
psql -U username dbname -f outputfile.sql
To restore from any file type, other than plain text (see above), created by pg_dump...
pg_restore -h myhost -U username -W -d mydatabase -v outputfile.sql
To restore our backup of all tables that start with "AO_8542F1"
pg_restore -h myhost -U atljira -W -d jira -v -c AO_8542F1.sql
In Jira, tables starting with AO_8542F1 relate to the Assets (previosuly Mindville Insight) functionality.