PostgreSQLのバックアップ |
2005/04/15 |
ちょこさんが情報提供してくださったので、ちょっとまとめました(ちょこさん情報のコピーです)。
PostgreSQLのパックアップ
postgress のルートユーザでログインします。
# su - postgres
バックアップを行います。「-F c」オプションで圧縮出力するようです。
postgres$ pg_dump -U postgres -F c -f <バックアップ・アーカイブ名.car> <データベース名>
PostgreSQLのデータベースをリストア
postgress のルートユーザでログインします。
# su - postgres
まず、リストアするデータベースがすでに存在する場合、それを削除します。
postgres$ dropdb {データベース名>
リストアするデータベースを新規生成します。
postgres$ createdb -U postgres -E EUC_JP <データベース名>
リストアします。
postgres$ pg_restore -U postgres -d <データベース名> -F c <バックアップ・アーカイブ名.car>
テーブルのリストア
postgress のルートユーザでログインします。
# su - postgres
リストア先の情報が残っている場合は、先に削除します。
postgres$ psql <データベース名>
psql# DROP TABLE <テーブル名>
psql# \q
リストアを実行します。
postgres$ pg_restore -U postgres -d <データベース名> -t <テーブル名> -F c <バックアップ・アーカイブ名.car>
|