Open5

【PostgreSQL12→15】アップデート手順(Windows)

なななな

DBのバックアップ

pgAdmin 4を利用して実施します。

任意のDBを右クリック→バックアップから作成できる

pg_dumpの場合

cd C:/Program Files/PostgreSQL/9.4/bin
pg_dump.exe --host [host_name] --port 5432 --username "postgres" --format
custom --blobs --encoding UTF8 --verbose --file "D:\work\backup\postgres.backup" "table_name"
なななな

PostgreSQL12の停止

サービスの管理 を使う場合

右クリック→停止
プロパティからスタートアップの種類を[無効]にする

コマンドからの場合

net stop postgresql-x64-12
なななな

PostgreSQL15 で新しいDBを作成する

pgAdmin 4

[データベース]を右クリック→作成→データベース…

createdb コマンドを使う場合

cd C:/Program Files/PostgreSQL/12/bin
createdb --username [username] --lc-collate C --lc-ctype C --
encoding=UTF8 --template=template0 tb_name
なななな

旧DBのデータをリストア

pgAdmin 4

作成したDBを右クリック→リストア

pg_restore コマンドを使う場合

cd C:/Program Files/PostgreSQL/12/bin
pg_restore.exe --host [host_name] --port "5432" --username "postgres" --
dbname "db_name" --clean --verbose "C:\work\postgres.backup"