7
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

docker-composeでインストールしたredmineからDBダンプ取得する

Last updated at Posted at 2015-11-10

2週くらい周ってやっとコンテナ便利かな?って思えて来ました。
久々に触ったら環境変わりすぎててビビった

参考

DBのダンプくらい取れないと使い物にならなそうだったので、ダンプ方法を調べたメモ。

docker-compose.yml 確認

設定周りが書いてあるdocker-compose.ymlに下記の記述を確認する

postgresql:
  image: sameersbn/postgresql:9.4-7
  environment:
    - DB_USER=redmine
    - DB_PASS=password
    - DB_NAME=redmine_production

対象サーバのIPアドレスを確認する

対象のCONTAINER IDを確認する

  # docker ps -a
  CONTAINER ID        IMAGE                        COMMAND                CREATED             STATUS              PORTS                            NAMES
  be78dd326cba        sameersbn/redmine:3.1.1-3    "/sbin/entrypoint.sh   About an hour ago   Up 35 minutes       443/tcp, 0.0.0.0:10083->80/tcp   docker_redmine_1
  562616aac362        sameersbn/postgresql:9.4-7   "/sbin/entrypoint.sh   About an hour ago   Up 35 minutes       5432/tcp                         docker_postgresql_1

対象のIPを確認する

  # docker inspect --format="{{ .NetworkSettings.IPAddress }}" 562616aac362
  172.17.0.18

この時点でpsqlで繋ごうとするとエラーが出る

  # psql -h 172.17.0.18 -dredmine_production
  パスワード:
  psql: FATAL:  password authentication failed for user "root"

ユーザがredmineじゃないとダメそう。

# psql -U redmine -h 172.17.0.18 -d redmine_production
ユーザ redmine のパスワード:
psql (9.4.5)
"help" でヘルプを表示します.

redmine_production=>

繋がった。ということでダンプ

 # pg_dump -U redmine -h 172.17.0.18 -d redmine_production > dump.sql

余談

yml見れば直感的に設定分かるし、compose便利すぎ

7
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?