Facebook
From Chunky Kitten, 1 Week ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 64
  1. -------------_Backup_--------------------
  2. //2.29
  3. pg_dump -O -Fp baocao -T aggregated* -T analytics* -T completeness* | gzip > ~/kln235_105.94.sql.gz
  4. //2.35
  5. pg_dump -O -U dhis -d dhis2 -Fp -T aggregated* -T analytics* -T completeness* | gzip > /var/lib/postgresql/data/20210607_kln_3191.94.sql.gz
  6. -------------_Restore_--------------------
  7. dropdb dqr;
  8. --Update ROLE by command ALTER
  9. sudo -u postgres psql -p 5432 -c "CREATE ROLE dqr PASSWORD 'SdySsf3Md1' NOSUPERUSER CREATEDB NOCREATEROLE INHERIT LOGIN;"
  10.  
  11. psql -c  "CREATE DATABASE dqr OWNER dqr ENCODING 'UTF-8' TEMPLATE template0;"
  12. psql -c  "GRANT ALL ON DATABASE dqr TO dqr;"
  13.  
  14. gunzip -c ./dhis2.sql.gz | psql -p 5432 dqr;
  15.  
  16. # make sure db owner owns everything
  17. pg_dump -p 5432 -s dqr | grep -i 'owner to' | sed -e "s/OWNER TO .*;/OWNER TO dqr;/i"|psql -p 5432 dqr
  18. exit
  19.  
  20. 13 19 * * * /usr/bin/dhis2-backup-kln-instance
  21.  
  22. psql -p 5432 -U dhis dhis2