- 자주 사용하는 postgresql dump 및 restore 명령어
-d DB명
-h : DB주소
-p : port번호
-U : 유저명
-F : 백업 포맷 지정 (p: plain-text, c: custom-format, d: directory, t: tar)
-f : 백업 파일명
-t : 특정 테이블명
-j : Backup시 병렬처리 여부 및 그 정도
-v : 진행 과정 표시
- 이외의 다른 명령어들은 공식 홈페이지를 참조
https://www.postgresql.org/docs/current/app-pgdump.html
pg_dump 예시
pg_dump -h localhost -p 5432 -d testdb -U postgres -v -F t > /backup/test_backup.tar
위의 명령어는 다음의 의미를 가지고 있다.
localhost의 5432포트에 postgres유저로 접속하여 testdb를 '/backup/test_backup.tar'파일에 상세과정을 표시하며 백업한다.
pg_restore 예시
pg_restore -h localhost -p 5432 -d targetdb -U postgres -v "C:/backup/test_backup.tar"
위의 명령어는 다음의 의미를 가지고 있다.
localhost의 5432포트에 postgres유저로 접속하여 targetdb에 '/backup/test_backup.tar' 파일을 상세과정을 표시하며 복원한다.
'서버 > DB' 카테고리의 다른 글
postgresql sequence 사용하기 (380) | 2023.08.24 |
---|---|
postgresql lock 테이블 조회 및 kill (959) | 2023.04.19 |
오라클 connect by level 사용법 (616) | 2022.02.15 |
Maximum execution time of 120 seconds exceeded (2) | 2021.11.04 |
오라클에서 인덱스가 없는 테이블에 인덱스 생성하기 (인덱스 생성을 빠르게) (2) | 2020.11.09 |
댓글