본문 바로가기

Programming/DB

PostgreSQL에서 테이블 백업(Dump)하기

터미널에서 아래 명령어를 실행하면 해당 테이블의 SQL이 덤프파일로 떨어진다.  

# 백업 : pg_dump -U {소유주} {DB명} -t {테이블명} > {백업파일명}
$ pg_dump -U postgres test_db -t test_table > db_backup.sql

 

(추가) 아래 명령어를 실행했을 때, pg_dump command를 찾을 수 없다는 경고가 뜨면 아래와 같이 전체 경로를 입력한다. 

 

$ /postgres/bin/pg_dump -U postgres test_db -t test_table > db_backup.sql

 

'Programming > DB' 카테고리의 다른 글

PostgreSQL에서 데이터 Insert문으로 백업하기  (0) 2021.05.10