PostgreSQL(ポスグレ) Windowsコマンドによるテーブル単位、DB単位のバックアップ、リストア

公開日: ITプロ

オープンソースのデータベースPostgreSQL(ぽすぐれえすきゅーえる)で、Windowsコマンドプロンプトで行うテーブル単位のバックアップとリストアコマンドをまとめました。以下のコマンドによって、「D:\table.log」というテキストファイルへログが出力されますので、バッチ処理に利用できます。


■テーブル単位のバックアップ ※ブログの表示上「バックスラッシュ」は「円マーク」が正です
C:\PostgreSQL\9.2\bin\pg_dump.exe --host localhost --port 5432 --username "postgres" --no-password --format tar --verbose --file "D:\table.backup" --table "public.\"table_mei\"" "db_mei" 2> D:\table.log


■テーブル単位のリストア
C:\PostgreSQL\9.2\bin\pg_restore.exe --host localhost --port 5432 --username "postgres" --dbname "db_mei" --no-password --data-only --table \"table_mei\" --schema public --verbose "D:\table.backup" 2> D:\table.log
  • ?±??G???g???[?d????u?b?N?}?[?N???A