Postgresql – Restoring schemas with the sequences

backuppostgresqlschemasequence

This evening a developer asked to restore only schemas from a database into another database.
A colleague of mine did this, but after that the developer came to me saying that the sequences are missing from the restored schema.

I think this was the command my colleague used to get a dump of the schema only :

/usr/local/pgsql915/bin/pg_dump -U backupuser --schema-only myegrtx -p 5432 -t tb_roadtax_kioskinfo -t tb_rtx_expdelivery_postcode -t tb_roadtax_inquiryinfo -t roadtax_tx_history -t tb_roadtax_payment_data_info -t tb_roadtax_renewalinfo -t tb_roadtax_kioskusers -t tb_roadtax_kioskuser_trans -t tb_roadtax_delivaryinfo -t tb_roadtax_asinfo  -t tb_roadtax_disk_print_info > myegrtxbike-schema.sql

And this was the command to restore it to the new db :

/usr/local/pgsql934/bin/psql -U postgres -d myegrtxbike -p 6434 -f srikanth/myegrtxbike-schema.sql

How do I now get the backup of and restore the sequences that have been reported missing?

I need some guide on this, as googling the commands is not a success (The commands do not work or I do not get the proper commands, especially for the sequence part).

Best Answer

Simply add -t <sequencename> for all the sequences you want to dump.