Skip to content

Instantly share code, notes, and snippets.

@TimKraemer
Last active October 24, 2018 13:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TimKraemer/a0bd511ff6cb01e84a8c23201899fbd1 to your computer and use it in GitHub Desktop.
Save TimKraemer/a0bd511ff6cb01e84a8c23201899fbd1 to your computer and use it in GitHub Desktop.
KMDB restore kmdb from dump
#!/bin/bash
cp -a $1 /tmp/kmdb.dump
sudo su postgres <<EOF
cd ~
dropdb db
createdb db --owner=kmdb --encoding=UTF8
pg_restore -l /tmp/kmdb.dump | sed '/MATERIALIZED VIEW DATA/d' > restore.lst
pg_restore -L restore.lst -d db /tmp/kmdb.dump > /dev/null 2>&1
pg_restore -l /tmp/kmdb.dump | grep 'MATERIALIZED VIEW DATA' > refresh.lst
psql -d db -c 'REFRESH MATERIALIZED VIEW unique_lexeme;'
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment