728x90
구글엔 없는게 없다..
https://stackoverflow.com/questions/24718706/backup-restore-a-dockerized-postgresql-database
Giovanni Aravena Morales 요 분이 쓰신 댓글을 참고 했고
명령은 아래와 같음
#백업
docker exec -t your-db-container pg_dumpall -c -U your-db-user > dump_$(date +%Y-%m-%d_%H_%M_%S).sql
#복원
cat your_dump.sql | docker exec -iT your-db-container psql -U your-db-user -d your-db-name
내 경우 복원 과정에서 아래와 같은 tty 오류가 나서
the input device is not a TTY. If you are using mintty, try prefixing the command with 'winpty'
-T 옵션을 붙여주니 정상적으로 작동했다.
여기서 -T옵션은 tty를 끄는거다. 현재 bash에서 cat으로 input을 가져오는데 그게 tty가 아니다보니,
docker compose 상의 bash는 tty로 구동되어 서로 맞춰주기 위해서 docker 쪽에서 tty를 꺼버린거다.
아마 윈도우와 리눅스 간의 서로다른 입력기 차이 때문에 제대로 데이터가 들어가지 않은듯하다.
728x90
'IT > Docker' 카테고리의 다른 글
docker compose 영구적인 로그 남기기. (0) | 2024.05.03 |
---|---|
Docker postgreSQL 자동 백업 및 수동 복원 방법 (0) | 2023.12.27 |
Docker postgresql 세팅을 제대로 했는데 접속 안될 때 (0) | 2023.12.14 |
Docker 종료된 container history 일괄삭제 (0) | 2021.11.09 |