Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 |
Tags
- OOM
- kerberosClient
- supserset
- webhdfs
- OutOfMemory
- PFX
- Keygen
- python3
- python2
- airflow
- distcp
- setdefault
- kerberos
- hive
- OpenSSL
- unquote
- hadoop
- Python
- encoding
- pyhive
- Linux
- executor
- Spark
- ssh
- install
- CRT
- Celery
Archives
- Today
- Total
복싱하는_개발자.dev
[postgresql] pg_dump, dumpall 을 이용한 백업과 복구 본문
postgresql 의 버전업 또는 다른 서버로의 이전으로 기존 데이터를 백업하고 복구 해야 하는 일이 생겼다.
이 때, 여러 postgresql 백업 방법 중 pg_dump, pg_dumpall 이 그나마 버전을 크게 타지 않고 백업이 가능해서 요 방법으로 진행하였다. (postgresql이 9.x 버전에서 12.x 버전으로 업그레이드가 되면서 많이 바뀌었다..!)
pg_dumpall & psql
pg_dumpall : 데이터 전체 내용을 백업. text 형태로 저장됨.
psql : 전체 내용을 복구함.
명령어:
//backup
pg_dumpall -f {덤프경로/dump.sql} -U postgres -h localhost
//restore
psql -U postgres -h localhost -f {덤프경로/dump.sql}
각 테이블의 role, tablespace 등이 모두 백업된다.
pg_dump & pg_restore
pg_dump : 특정 1개의 데이터 베이스만 백업 가능. text 형태 X
pg_restore: 비텍스트 파일로 복구함. 해당 테이블의 role, tablespace는 모두 복구 되지 않음.
만약 특정 유저가 생성 되었었거나 권한을 주었을 경우에는 다시 모두 재설정을 해주어야함.
// backup
pg_dump -Fc {db명} -h localhost -U postgres > {저장파일명.dump}
// restore
pg_restore -U postgres -h localhost -d {db명} < {저장파일명.dump}'DB' 카테고리의 다른 글
| [Hive] pyHive로 Kerberos 인증 하고 Hive 연결 (0) | 2022.03.16 |
|---|
Comments