본문 바로가기

DATABASE/POSTGRESQL

psql 명령어를 사용하여 원격지 DataBase 복원해보기

먼저 psql 명령어 사용을 위해 postgresql 서버를 설치한다. (클라이언트 도구가 포함되어 있음 #psql)

brew install postgresql

리눅스 환경의 경우 클라이언트 도구를 설치 할 수 있음

sudo apt-get install postgresql-client

psql을 사용하여 Database 복원을 하기위한 명령어 필요

psql -h <호스트> -p <포트> -U <사용자> -d <데이터베이스> -f <백업파일>

원격지 DB는 도커에서 실행 중인 postgresql DB로 가정한 명령어

psql -h localhost -p 5432 -U myuser -d mydatabase -f /path/to/backup.sql