Re: pg_restore
От | Ron |
---|---|
Тема | Re: pg_restore |
Дата | |
Msg-id | 7da46322-6a20-ef30-2a95-1cafbc8e5e75@gmail.com обсуждение исходный текст |
Ответ на | Re: pg_restore (Ron <ronljohnsonjr@gmail.com>) |
Список | pgsql-admin |
On 4/11/19 6:12 PM, Ron wrote:
But it just occurred to me that I used directory backups, not custom backups, so this probably won't work for you.
On 4/11/19 5:09 PM, rammohan ganapavarapu wrote:Hi,I have a custome database called mudb along with default databases in my postgresql cluster, i am trying to restore mydb from a custom format pg_dump file, what is the procedure to do it?psql -t -h localhost -U ${RUN_USER} -c "SELECT pg_terminate_backend(pg_stat_activity.pid) FROM pg_stat_activity WHERE pg_stat_activity.datname = 'mydb' AND pid <> pg_backend_pid();"pg_restore" -h localhost -U ${RUN_USER} -d mydb -j "${JOBS}" -x -O -C -c --if-exist -v pgdump.dumpBut i am getting below error:pg_restore: connecting to database for restorepg_restore: dropping DATABASE mydbpg_restore: [archiver (db)] Error while PROCESSING TOC:pg_restore: [archiver (db)] Error from TOC entry 4312; 1262 16384 DATABASE mydb mydbpg_restore: [archiver (db)] could not execute query: ERROR: cannot drop the currently open databaseCommand was: DROP DATABASE IF EXISTS mydb;So what is the best way to restore? I am using 9.6 version.
I made the same mistake you did, by doing "-d mydb". You need to specify the postgres database.
This works for me:
export PGUSER=${RUN_USER}
export PGHOST=localhost
DB=mydb
pg_restore -xOvcC --if-exists --jobs=${JOBS} -d postgres ${DB} 2> ${DB}_restore.log
But it just occurred to me that I used directory backups, not custom backups, so this probably won't work for you.
--
Angular momentum makes the world go 'round.
Angular momentum makes the world go 'round.
В списке pgsql-admin по дате отправления: