Skip to content

Latest commit

 

History

History
executable file
·
33 lines (30 loc) · 888 Bytes

File metadata and controls

executable file
·
33 lines (30 loc) · 888 Bytes

How to copy production database locally

  1. login to remote server, and get into postgres container via:
docker-compose -f production.yml exec postgres /bin/bash
  1. scp the backup from the server if restoring to local env:
pg_dump -U $POSTGRES_USER -d smart -f smart.sql
mv smart.sql docker-entrypoint-initdb.d/

  1. move smart.sql to ~ and copy the dump using scp
 scp smart:smart.sql .
  1. Modify the smart.sql file
  • add the lines DROP SCHEMA PUBLIC cascade;CREATE SCHEMA PUBLIC; to the top.
  • replace the user with 'postgres'
  • add users:
    CREATE ROLE smart_anonymous;
    CREATE ROLE smart_user;
    
  1. stop the docker containers. remove all containers, and delete all volumes.
docker container prune -f
docker volume prune -f
  1. Move the file into postgres folder.
  2. docker-compose up postgres
  3. delete the smart.sql file