Guest User

Untitled

a guest
May 25th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. DUMP='/mnt/backup/pg_backups/pgdump_pp_2010-03-07T03:06:11'
  4. TMP_DATABASE=message_restore_tmp
  5. TABLES='group_info group_group group_data group_name discuss_subject discuss_course discuss_subject_subscribe message message_read message_node message_label_coupling discuss_post_root'
  6. PREFIX=message_restore_
  7.  
  8. psql pp pgsql -c "CREATE DATABASE $TMP_DATABASE"
  9.  
  10. for TABLE in $TABLES; do
  11. pg_restore -U pgsql -Fc -t $TABLE "$DUMP" | psql $TMP_DATABASE pgsql
  12. NEWTABLENAME=${PREFIX}${TABLE}
  13. psql $TMP_DATABASE pgsql -c "ALTER TABLE $TABLE RENAME TO $NEWTABLENAME"
  14. pg_dump -Fc -U pgsql $TMP_DATABASE > dump_$TABLE.tar
  15. pg_restore -U pgsql -Fc -t $NEWTABLENAME dump_$TABLE.tar | psql pp pgsql
  16. done
Add Comment
Please, Sign In to add comment