Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- DUMP='/mnt/backup/pg_backups/pgdump_pp_2010-03-07T03:06:11'
- TMP_DATABASE=message_restore_tmp
- 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'
- PREFIX=message_restore_
- psql pp pgsql -c "CREATE DATABASE $TMP_DATABASE"
- for TABLE in $TABLES; do
- pg_restore -U pgsql -Fc -t $TABLE "$DUMP" | psql $TMP_DATABASE pgsql
- NEWTABLENAME=${PREFIX}${TABLE}
- psql $TMP_DATABASE pgsql -c "ALTER TABLE $TABLE RENAME TO $NEWTABLENAME"
- pg_dump -Fc -U pgsql $TMP_DATABASE > dump_$TABLE.tar
- pg_restore -U pgsql -Fc -t $NEWTABLENAME dump_$TABLE.tar | psql pp pgsql
- done
Add Comment
Please, Sign In to add comment