Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
72
Help us understand the problem. What is going on with this article?
@tatataiki

PostgreSQLのDBを複製する方法

More than 5 years have passed since last update.

1つの案件で複数のカスタマイズを同時に行っている時にそれぞれ違う変更をDBに行う必要があり
同じDBを複数用意する必要があったので調べた時のメモ。
一時的なバックアップにも便利かも。

コマンド1

createdb -T ORG_DB_NAME NEW_DB_NAME

コマンド2

上記のコマンドは、DBを使用中だと怒られれるので
その場合は、下記コマンド

createdb NEW_DB_NAME
pg_dump -Ft ORG_DB_NAME | pg_restore -d NEW_DB_NAME

備考

ORG_DB_NAME:コピー元のDB名
NEW_DB_NAME:新しく作るDB名

72
Help us understand the problem. What is going on with this article?
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away

Comments

No comments
Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account Login
72
Help us understand the problem. What is going on with this article?