0
0

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 1 year has passed since last update.

PostgreSql dump取得コマンド

Posted at

書いた理由

AWSのRDSでPostgreSqlの本番DBのリストアとdump取得コマンドよく忘れるので備忘録的にメモろうと思います。

dump取得コマンド

ssh -i ファイル名.pem ubuntu@IPアドレス
pg_dump -Fc -U postgres -h エンドポイント -d DB名 > dumpファイル名

マスターパスワードも要求されるので調べておくこと。

dump取得コマンド

①docker desktopでdbコンテナ再起動(接続切るため)

②cd docker (プロジェクトのディレクトリ)

③docker compose exec web bash

④dropdb -U postgres -h コンテナ名 DB名

⑤createdb -U postgres -hコンテナ名 DB名

⑥pg_restore -U postgres -h コンテナ名 -d DB名 < dumpファイル名

以上です。
誰かの参考になれば幸いです。

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?