LoginSignup
1
3

More than 5 years have passed since last update.

PostgreSQLのDBをgzip形式でバックアップ・リストア

Posted at

やること

ただ単純にPostgreでDBのバックアップとリストアを行います。

1.バックアップ

$ pg_dump -U [ユーザ名] [db名] | gzip > [ファイル名.gz]

2.DB内データ削除

$ psql -U [ユーザ名] [db名]
> SELECT current_schema;
> DROP SCHEMA public CASCADE;
> CREATE SCHEMA public;

3.リストア

$ gzip -cd [ファイル名.gz] | psql -U [ユーザ名] -d [db名]
1
3
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
1
3