2016-06-22 13 views
1

포스트 그레스 버전 :pg_restore에 중복 키 및 잘못된 명령 오류

PostgreSQL 9.2.4 on x86_64-unknown-linux-gnu, compiled by gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-3), 64-bit 

우리는 VM 컨버터를 사용하여 우리의 시스템 (더 나은 CPU 램 (RAM)와 함께) 한 서버에서 다른 서버로 전송하고 내가 백업 데이터베이스에하려고하면 오류가 :

pg_dump: reading schemas 
pg_dump: reading user-defined tables 
pg_dump: reading extensions 
pg_dump: reading user-defined functions 
pg_dump: reading user-defined types 
pg_dump: reading procedural languages 
pg_dump: reading user-defined aggregate functions 
pg_dump: reading user-defined operators 
pg_dump: reading user-defined operator classes 
pg_dump: reading user-defined operator families 
pg_dump: reading user-defined text search parsers 
pg_dump: reading user-defined text search templates 
pg_dump: reading user-defined text search dictionaries 
pg_dump: reading user-defined text search configurations 
pg_dump: reading user-defined foreign-data wrappers 
pg_dump: reading user-defined foreign servers 
pg_dump: reading default privileges 
pg_dump: reading user-defined collations 
pg_dump: reading user-defined conversions 
pg_dump: reading type casts 
pg_dump: reading table inheritance information 
pg_dump: reading rewrite rules 
pg_dump: finding extension members 
pg_dump: finding inheritance relationships 
pg_dump: reading column info for interesting tables 
pg_dump: finding the columns and types of table "account_account" 
pg_dump: [archiver (db)] query failed: ERROR: missing chunk number 0 for toast value 3297740 in pg_toast_2619 
pg_dump: [archiver (db)] query was: SELECT a.attnum, a.attname, a.atttypmod, a.attstattarget, a.attstorage, t.typstorage, a.attnotnull, a.atthasdef, a.attisdropped, a.attlen, a.attalign, a.attislocal, pg_catalog.format_type(t.oid,a.atttypmod) AS atttypname, array_to_string(a.attoptions, ', ') AS attoptions, CASE WHEN a.attcollation <> t.typcollation THEN a.attcollation ELSE 0 END AS attcollation, pg_catalog.array_to_string(ARRAY(SELECT pg_catalog.quote_ident(option_name) || ' ' || pg_catalog.quote_literal(option_value) FROM pg_catalog.pg_options_to_table(attfdwoptions) ORDER BY option_name), E', 
    ') AS attfdwoptions FROM pg_catalog.pg_attribute a LEFT JOIN pg_catalog.pg_type t ON a.atttypid = t.oid WHERE a.attrelid = '274619'::pg_catalog.oid AND a.attnum > 0::pg_catalog.int2 ORDER BY a.attrelid, a.attnum 

은 내가 pg_dump -U postgres my_db > /home/mydb.backup을 시도하고 성공적인 된 후에는, reindexdb를 사용하여 해결한다.

ERROR : extra data after last expected column 
Context: COPY tbl1, line1: "1 2013-12-02 2013-12-02 9387.74 9775.46211485490864940000" 6180.9500000000 80262 ...." 
ERROR : column "id" of relation "tbl1" does not exists 
invalid command \N 
invalid command \N 
invalid command \N 
..... 
invalid command \N 
invalid command \. 
ERROR: syntax error at or near "87685" 
LINE 1: 87685 SO87690 1 170468 2015-05-30 2015 05 30 
     ^
invalid command \. 

ERROR: duplicate key value violates unique constraint "ir_act_client_pkey" 
DETAIL: Key (id)=(103) already exists. 
CONTEXT: COPY ir_act_client, line 21: "" 
ERROR: duplicate key value violates unique constraint "ir_act_report_xml_pkey" 
DETAIL: Key (id)=(733) already exists. 
CONTEXT: COPY ir_act_report_xml, line 59: "" 
ERROR: duplicate key value violates unique constraint "ir_act_server_pkey" 
DETAIL: Key (id)=(703) already exists. 
CONTEXT: COPY ir_act_server, line 6: "" 
ERROR: duplicate key value violates unique constraint "ir_act_window_pkey" 
DETAIL: Key (id)=(1) already exists. 
CONTEXT: COPY ir_act_window, line 235: "334 Last Product Inventories  ir.actions.act_window \N  1  2013-07-03 10:39:48.399509 2013-12-16 16:38:..." 
ERROR: duplicate key value violates unique constraint "ir_act_window_group_rel_act_id_gid_key" 
DETAIL: Key (act_id, gid)=(76, 1) already exists. 
CONTEXT: COPY ir_act_window_group_rel, line 14: "" 
ERROR: duplicate key value violates unique constraint "ir_act_window_view_pkey" 
DETAIL: Key (id)=(100) already exists. 
CONTEXT: COPY ir_act_window_view, line 88: "" 

어떻게 그것을 해결하기 : 그럼 그 백업이 유효한지 확인하기 위해 데이터베이스를 복원하려고

psql -U postgres new_db < /home/mydb.backup 

와 오류가?

+0

pg_dump -Fc를 사용하여 덤프를 시도하고 얻은 결과를 확인하십시오. – e4c5

+0

@ e4c5 조언을 주셔서 감사합니다. 데이터베이스가로드되었으므로 지금 백업 할 수 없습니다. 오늘 밤 시도하겠습니다. – GeoVIP

+0

-Fc로 시도하고 파일은 백업 후 12GB, 데이터베이스는 20GB, -Fc 없이는 30GB였습니다.이 12GB 파일을 복원하려고 시도하면 오류가 발생합니다. '오류 : 구문 오류 또는 "PGDMP" 줄 1 : SCHEMA의 PGDMPREVOKE ALL (모두에서 공용) postgres에서 공개; ^ GRANT GRANT GRANT ERROR : 구문 오류 " LINE 1 ''AT OR 가까운 위치"INTEGER, ^ ERROR : 구문 오류 AT OR 근처 " LINE 1"LANGUAGE C의 STRICT' – GeoVIP

답변

0

데이터를 내보낼 때 을 -Fc 옵션과 함께 사용하십시오.

Output a custom-format archive suitable for input into pg_restore. Together with the directory output format, this is the most flexible output format in that it allows manual selection and reordering of archived items during restore. This format is also compressed by default.

간결한 형식을 사용하면 서버간에 쉽게 전송할 수 있으며 IO로드에 따라 덤프 및 복원도 빨라질 수 있습니다.

이미 일부 테이블이 포함 된 데이터베이스로 데이터를 가져 오려는 경우 필연적으로 복잡합니다. --clean 옵션을 사용하여 덤프하면이 상황을 극복 할 수 있습니다.