sequence sync option with pg_dump

182 views Asked by At

I use pg_dump to backup and restore to target and manually sync (using setval function) sequences on tables. Is following an option to avoid manual sync or manual sync is always required?

pg_dump -s (schema-only) + pg_dump -a (only data from tables/LOB/Sequence Values) 

And then i use pg_restore in same order which sync the sequences automatically

1

There are 1 answers

0
Laurenz Albe On

To get a script that sets the value of a sequence seq, you can run a data-only pg_dump for this sequence:

pg_dump -a -t seq