pg_restore is a utility for restoring a PostgreSQL database from an archive created by pg_dump in one of the non-plain-text formats.
pg_restore
은 pg_dump
가 만든 아카이브 백업 파일에서 PostgreSQL 데이터베이스를 복원하기 위해 사용하는 유틸리티입니다.
pg_restore
은 두 가지 모드로 작동할 수 있습니다.
pg_restore
은 해당 데이터베이스에 연결하고 아카이브 내용을 데이터베이스에 직접 복원합니다.pg_dump
의 일반 텍스트 출력 형식과 동일하며, 그 출력을 제어하는 일부 옵션은 pg_dump
와 유사합니다.pg_restore [connection-option...] [option...] [filename]
mydb라는 데이터베이스를 사용자 지정 형식으로 백업했을 경우
pg_dump -Fc mydb > db.dump
데이터베이스를 삭제하고 덤프 파일에서 재 생성할 경우
dropdb mydb
pg_restore -C -d postgres db.dump
newdb라는 새로운 데이터베이스에 복원 할 경우
createdb -T template0 newdb
pg_restore -d newdb db.dump
데이터베이스 리스트의 순서를 변경하려면 먼저 리스트를 덤프 해야 합니다.
pg_restore -l db.dump > db.list
각 리스트 파일은 헤더와 각 리스트로 구성됩니다.
;
; Archive created at Mon Sep 14 13:55:39 2009
; dbname: DBDEMOS
; TOC Entries: 81
; Compression: 9
; Dump Version: 1.10-0
; Format: CUSTOM
; Integer: 4 bytes
; Offset: 8 bytes
; Dumped from database version: 8.3.5
; Dumped by pg_dump version: 8.3.8
;
;
; Selected TOC Entries:
;
3; 2615 2200 SCHEMA - public pasha
1861; 0 0 COMMENT - SCHEMA public pasha
1862; 0 0 ACL - public pasha
317; 1247 17715 TYPE public composite pasha
319; 1247 25899 DOMAIN public domain0 pasha
Semicolons start a comment, and the numbers at the start of lines refer to the internal archive ID assigned to each item.
Lines in the file can be commented out, deleted, and reordered. For example:
10; 145433 TABLE map_resolutions postgres
;2; 145344 TABLE species postgres
;4; 145359 TABLE nt_header postgres
6; 145402 TABLE species_records postgres
;8; 145416 TABLE ss_old postgres
위 리스트는 pg_restore에 대한 입력으로 사용할 수 있으며, 항목 10과 6만 다음 순서로 복원할 경우
$ pg_restore -L db.list db.dum