-
Notifications
You must be signed in to change notification settings - Fork 1
[TECH] ver 3.35.x : postgreSQL dump and restore
Ingi Erli edited this page Dec 2, 2019
·
2 revisions
https://www.postgresql.org/docs/9.1/backup-dump.html
History-edit : latest =2019-12-02
database is seqdb_prod
- pg_dump -U 'dbname' > outfile
- pg_dump -U postgres seqdb_prod > seqdb_prod-20191025.sql
#!/bin/bash
source ../env/.env.postgres
NOW=`date +"%Y-%m-%d"`
TARGET=../db-backup
docker exec shared_db sh -c 'exec pg_dump -U postgres seqdb_prod' > ${TARGET}/${POSTGRES_DB}_${NOW}.sql
echo $NOW >> biobackup.log
scp ${TARGET}/${POSTGRES_DB}_${NOW}.sql biobackup:/backup/SEQDB &>>biobackup.log
proof-of-concept
(A) Pre-req
- edit the docker-compose.yml-file; use a new volume
- run 'make',
- seqdb-lab.nrm.se - login as 'Admin'
- Specimen and Samples should be empty
(B) restore Syntax : psql -U 'dbname' < infile
-
drop schema seqdb cascade;
-
psql -U postgres -d seqdb_prod < seqdb_prod_2019-11-20.sql
-
docker cp seqdb_prod_2019-11-20.sql shared_db:/tmp
-
docker exec -it shared_db bash
-
cd /tmp
-
psql -U postgres seqdb_prod < seqdb_prod_2019-11-20.sql or psql -h localhost -U postgres -d seqdb_prod -f seqdb_prod_2019-11-20.sql
-
docker-compose down , make
- docker exec -it shared_db bash
- psql -d seqdb_prod -U postgres
- SET search_path TO seqdb;
- select * from seqdb.accounts or (select * from accounts , works if search_path is correct)
- add user
- add account
- add group -> 'NRM-CGI' -> all 'rights'
- add specimen collection ->