PostgreSQL 데이터베이스 백업 및 복구 pd_dump의 pg_restore에

PG는 데이터베이스 백업 파일이있을 수 있습니다 생성 한 SQL 파일, 바이너리 파일이며, 바이너리 파일은 pg_restore의를 사용하여 복원 할 수 있습니다.

 

간단한 설명 PostgreSQL 데이터베이스 작업

PostgreSQL 데이터베이스 버전

psql 프로그램의 --version의
psql의 (PostgreSQL의) 9.1.3

 

리눅스에서 동작이되는 다음, 창문은 스와 -postgres 대체됩니다

유형 실행에 cmd → D : →

CD D는 : \ 프로그램 파일 \의 PostgreSQL \ 9.2 \ 빈은 다음 표를 작성, 테이블을 삭제하면, 포스트 그레스에서 작동해야하고, 따라서 -u 포스트 그레스 입력 psql를 삭제 데이터베이스 앞을 작성해야

첫째, 데이터베이스 백업

한 백업 데이터베이스 구조

SU - 포스트 그레스
pg_dump의 -Fc -s -f testdbschema.sql TESTDB

2, 데이터베이스의 데이터를 백업

SU - 포스트 그레스
pg_dump의 -Fc -a -f testdbdata.sql TESTDB

(3), 백업 데이터베이스 구조 및 데이터

SU - 포스트 그레스
pg_dump의 -Fc -f testdbschemadata.sql TESTDB

4, 백업 테이블 구조는 데이터베이스에 지정된

 pg_dump의 -Fc -s -t citycode -f citycode_schema.sql TESTDB

5, 백업 데이터는 데이터베이스 테이블에 지정된

 pg_dump의 -Fc -a -t citycode -f citycode_data.sql TESTDB

0.6, 지정된 백업 데이터베이스 테이블 (및 데이터 구조)

 pg_dump의 -Fc -t citycode -f citycode_schemadata.sql TESTDB

둘째, 데이터베이스를 삭제

SU - 포스트 그레스

dropdb의 TESTDB

셋째, 데이터베이스를 복원

1, 새로운 데이터베이스 TESTDB를 만들

SU - 포스트 그레스

CREATEDB의 TESTDB;


2 복구 데이터 구조 (스키마 만)

SU - 포스트 그레스

 pg_restore의 -s -d testdb라는 testdbschema.sql 
 

3, 데이터베이스, 데이터 복구 (데이터 전용)

SU - 포스트 그레스

pg_restore의 -a -d testdb라는 testdbdata.sql

4, 데이터베이스 구조 및 데이터 복구 (데이터 스키마)

SU - 포스트 그레스

pg_restore의 -d TESTDB testdbschemadata.sql

도 5에서, 테이블 데이터 복구를 지정할

1) 테이블 삭제

psql의의 TESTDB

표 citycode을 DROP;

2) 복구 테이블 구조

pg_restore의 -s -t citycode -d testdb라는 citycode_schema.sql

3) 테이블 데이터를 복원

pg_restore의 -a -t citycode -d testdb라는 citycode_data.sql

4) 복구 테이블 (데이터 구조)

pg_restore의 -t citycode -d testdb라는 citycode_schemadata.sql

정적 (데이터 없음 성장) 데이터베이스 백업 및 복구 관련 동작 이상.

중요 : pg_restore에는 pg_dump의 명령 데이터 파일 (FC \ 피트) 형식으로 백업을 복원 할 수 있습니다. 이 형식의 매개 변수 선언 pg_dump를 더 백업 명령 실행이없는 경우 pg_restore에 복원 할 때 오류 메시지가 발생할 수 있습니다 "pg_restore의를 : [아카이브] 입력 파일이 유효한 아카이브가 아닙니다."

 

 

공식 문서를 pg_dump의

https://www.postgresql.org/docs/10/app-pgdump.html

pg_dumpall의

https://www.postgresql.org/docs/10/app-pg-dumpall.html

pg_restore의

https://www.postgresql.org/docs/10/app-pgrestore.html

추천

출처www.cnblogs.com/ryanzheng/p/11295573.html