pg_dump -Cs DB_NAME > /tmp/schema_dump
-C switch adds the CREATE statements
-s switch specifies dumping only the schema not the data
If you want the data as well then use
pg_dump -C DB_NAME > /tmp/schema_dump
If you want ONLY the data and not the database or table CREATE statements then use
pg_dump -a DB_NAME > /tmp/data_dump
All of the above dump the data as COPY commands which are faster but may not be compatible with other database engines.
If you want to dump data from postgres into another database then dump as INSERT statements by using
pg_dump -D DB_NAME > /tmp/data_dump_as_inserts
This uses the INSERT INTO table (col1, col2) VALUES (val1, val2) format. Using a lowercase "d" omits the column mappings for a slight increase in speed if you know the table is structured in the same way on the target database.
To restore the data:
createdb -T template0 dbname
psql dbname < infile
psql dbname < infile
First good blog I found on this. Thank you