PostgreSQL を pg_dump でバックアップ

 
ちょっとしたデータが入ってるだけの Postgres を別ホストに移したかったのでメモ

pg_dump でデータベースをダンプする。

$ pg_dump -h 10.0.0.1 -U postgres -d testdb > testdb.sql

ダンプした SQL ファイルを psql コマンドで新しいサーバーに流し込む。

$ psql -h 10.0.0.2 -U postgres -d testdb < testdb.sql