postgresql DB clone하기

yc999·2020년 12월 30일
0
post-thumbnail

하고 싶은 것. : PostgreSQL의 A db에서 사용하고 있는 모든 테이블과 테이블에 저장되어 있는 정보들을 A-test db로 clone (dump and restore) 하고 싶다.

다음과 같이 pg_dump tool을 이용해서 간단하게 할 수 있다.

$ pg_dump -f dump.sql -U {USER_ID} -h {HOST_ADDRESS} -d {SOURCE_DB_NAME} # dump
$ psql -f dump.sql -U {USER_ID} -h {HOST_ADDRESS} -d {TARGET_DB_NAME} # restore
# overwrite existing DB
$ pg_dump -f dump.sql -U {USER_ID} -h {HOST_ADDRESS} -d {SOURCE_DB_NAME} --clean # dump
$ psql -f dump.sql -U {USER_ID} -h {HOST_ADDRESS} -d {TARGET_DB_NAME} # restore
profile
꼬물꼬물 앞으로 가는 중

0개의 댓글