Production database
Downloading production database dump
This will download a copy of the production database, excluding the versions
and watched_productions
table, as they are quite big.
pg_dump --no-owner --no-privileges \
--exclude-table-data versions --exclude-table-data watched_productions \
--host mc-video.ccttdqnmswsr.eu-west-1.rds.amazonaws.com \
--format custom --dbname mc_video --username postgres > latest.dump
Importing the database dump locally
This will restore the previously downloaded dump in your local database.
pg_restore \
--no-privileges --no-owner \
--host localhost --username [your local postgresql username]
--dbname makers_development latest.dump
Syncing to preview
This first command does a 'delete' and 'create' of the database, which allows connections to remain active:
psql \
--no-psqlrc
--command "DROP SCHEMA public CASCADE; CREATE SCHEMA public;"
postgres://postgres@test-mc-video.ccttdqnmswsr.eu-west-1.rds.amazonaws.com:5432/test_mc_video
This second command imports the dump into preview:
pg_restore \
--no-privileges --no-owner \
--host test-mc-video.ccttdqnmswsr.eu-west-1.rds.amazonaws.com \
--dbname test_mc_video --username postgres \
latest.dump