일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
- 19c tde
- pg_basebackup
- oracle error
- db upgrade
- PostgreSQL 테이블스페이스 관리
- pg_dumpall
- PostgreSQL 외부 접속 방법
- PostgreSQL Parameter
- PostgreSQL 기동 정지
- sql문 전체 출력 방법
- 아카이브로그 삭제
- pgcrypto
- PostgreSQL 테이블스페이스 생성 삭제
- PostgreSQL Vacuum
- PostgreSQL Backup and Recovery
- Linux
- oracle
- PostgreSQL Database 관리
- PostgreSQL 아키텍처
- PostgreSQL 스키마 관리
- PostgreSQL SQL 처리 과정
- table lock 조치 방법
- pg_hba.conf
- sql문 짤릴 때
- PostgreSQL Admin
- Database 생성 삭제 조회 변경
- psql 복구
- PostgreSQL Parameter 설정 방법
- PostgreSQL Install
- multitenant
- Today
- Total
인성장
[PostgreSQL] Recovery - pg_restore 본문
pg_restore
pg_restore
pg_restore 명령어는 파일 포맷 형식(-F)을 기본값인 일반 텍스트 형식(plain)이 아닌 다른 형식[custom | tar | directory]을 지정하여 백업받은 파일을 복구할 때 사용합니다. pg_restore는 psql와 달리 다양한 옵션들을 이용하여 원하는 데이터(예: 특정 객체(테이블, 인덱스 등)) 를 복구할 수 있는 장점이 있습니다.
pg_restore 명령어를 사용하여 복구하는 경우
1. pg_dump로 파일 포맷 형식(-F)이 [plain]이 아닌 [custom | tar | directory]을 지정하여 백업받은 경우
2. 특정 객체(테이블, 인덱스 등)만 복구하고 싶은 경우
pg_restore 복구 시 기본 사용법
pg_restore [backupfile_name] -d [database_name] -U [user_name]
* 아래 모든 예제는 사용자 지정 형식(custom)으로 백업받은 파일로 복구하는 예제입니다.
* pg_restore 복구시에는 자동으로 백업파일형식을 읽기 때문에 -F 옵션을 생략해도 무방합니다.
* 1~3번 예제는 데이터베이스를 미리 생성해 놓아야 동작합니다.
1. pg_test DB 전체 복구 방법
$ pg_restore -Fc pg_test_fc.dump -d pg_test -U postgres -v
2. pg_test DB에 특정 테이블 복구 방법 (-t 옵션 사용)
pg_restore -Fc test_fc.dump -d pg_test -U postgres -t [table_name] -v
3. pg_test DB 복구 간, 기존 동일 테이블 존재하면 삭제 후 재생성하도록 하는 방법 (--if-exists, -c 옵션 사용)
$ pg_restore -d pg_test -U postgres pg_test_full.dump --if-exists -c -v
4. pg_test DB도 생성해주면서 데이터 복구하는 방법 (-C 옵션 사용)
$ pg_restore -d template1 -U postgres pg_test_full.dump -C -v
https://www.postgresql.org/docs/current/app-pgrestore.html
pg_restore
pg_restore pg_restore — restore a PostgreSQL database from an archive file created by pg_dump Synopsis pg_restore [connection-option...] [option...] [filename] Description …
www.postgresql.org
https://checktech.tistory.com/28
[PostgreSQL] Backup - pg_dump
pg_dump pg_dump pg_dump를 수행하면 데이터베이스에 생성된 객체와 데이터들을 기본적으로 SQL 구문 텍스트 형식으로 백업을 받습니다. SQL형식으로 쿼리가 출력되기 때문에, 복원하려는 PostgreSQL 버전
checktech.tistory.com
'PostgreSQL > Admin' 카테고리의 다른 글
[PostgreSQL] Recovery - psql (0) | 2024.03.15 |
---|---|
[PostgreSQL] Backup - pg_basebackup (0) | 2024.03.14 |
[PostgreSQL] Backup - pg_dumpall (0) | 2024.03.14 |
[PostgreSQL] 백업 복구 방식 (0) | 2024.02.27 |
[PostgreSQL] Backup - pg_dump (0) | 2024.02.26 |