2024-06-20 15:53:35 -05:00
|
|
|
{ postgresql_15, postgresql_16, writeScriptBin, ... }:
|
2024-04-09 16:27:27 -05:00
|
|
|
|
|
|
|
|
let
|
2024-06-11 09:40:23 -05:00
|
|
|
newPostgres = postgresql_16;
|
|
|
|
|
oldPostgres = postgresql_15;
|
2024-04-09 16:27:27 -05:00
|
|
|
in writeScriptBin "upgrade-pg-cluster" ''
|
|
|
|
|
set -eux
|
|
|
|
|
systemctl stop postgresql
|
|
|
|
|
|
|
|
|
|
export NEWDATA="/var/lib/postgresql/${newPostgres.psqlSchema}"
|
|
|
|
|
export NEWBIN="${newPostgres}/bin"
|
|
|
|
|
|
|
|
|
|
export OLDDATA="/var/lib/postgresql/${oldPostgres.psqlSchema}"
|
|
|
|
|
export OLDBIN="${oldPostgres}/bin"
|
|
|
|
|
|
|
|
|
|
install -d -m 0700 -o postgres -g postgres "$NEWDATA"
|
|
|
|
|
cd "$NEWDATA"
|
|
|
|
|
sudo -u postgres "$NEWBIN/initdb" -D "$NEWDATA"
|
|
|
|
|
|
|
|
|
|
sudo -u postgres "$NEWBIN/pg_upgrade" \
|
|
|
|
|
--old-datadir "$OLDDATA" --new-datadir "$NEWDATA" \
|
|
|
|
|
--old-bindir "$OLDBIN" --new-bindir "$NEWBIN" \
|
|
|
|
|
"$@"
|
|
|
|
|
''
|