Skip to content

Instantly share code, notes, and snippets.

@januszm
Last active May 25, 2022
Embed
What would you like to do?
Postgresql dump and load compressed
sudo amazon-linux-extras install postgresql12
pg_dump -Fc -h yyy-production.xxx.region.rds.amazonaws.com -p 5432 -U yyy yyy_production -f yyy.dump
# TRUNCATE TABLE tables ... RESTART IDENTITY
# rails db:migrate
pg_restore -Fc --data-only -h yyy-staging.xxx.region.rds.amazonaws.com -d yyy_staging -U yyy yyy.dump
# both commands accept the --table option to specify which table to dump/restore
# select setval('TABLE_NAME_id_seq', (select max(id)from TABLE_NAME)); may be required after RESTART IDENTITY, +1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment