-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
29 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,34 @@ | ||
{ config, pkgs, ... }: | ||
{ | ||
environment.systemPackages = [ | ||
(let | ||
# Specify the postgresql package you'd like to upgrade to. | ||
# Do not forget to list the extensions you need. | ||
newPostgres = pkgs.postgresql_16.withPackages (pp: [ | ||
# pp.plv8 | ||
]); | ||
in pkgs.writeScriptBin "pg-upgrade-cluster" '' | ||
set -eux | ||
# It's perhaps advisable to stop all services that depend on postgresql | ||
systemctl stop postgresql | ||
( | ||
let | ||
# Specify the postgresql package you'd like to upgrade to. | ||
# Do not forget to list the extensions you need. | ||
newPostgres = pkgs.postgresql_16.withPackages (pp: [ | ||
# pp.plv8 | ||
]); | ||
in | ||
pkgs.writeScriptBin "pg-upgrade-cluster" '' | ||
set -eux | ||
# It's perhaps advisable to stop all services that depend on postgresql | ||
systemctl stop postgresql | ||
export OLDBIN="${config.services.postgresql.package}/bin" | ||
export OLDDATA="${config.services.postgresql.dataDir}" | ||
export OLDBIN="${config.services.postgresql.package}/bin" | ||
export OLDDATA="${config.services.postgresql.dataDir}" | ||
export NEWBIN="${newPostgres}/bin" | ||
export NEWDATA="/var/lib/postgresql/${newPostgres.psqlSchema}" | ||
export NEWBIN="${newPostgres}/bin" | ||
export NEWDATA="/var/lib/postgresql/${newPostgres.psqlSchema}" | ||
install -d -m 0700 -o postgres -g postgres "$NEWDATA" | ||
cd "$NEWDATA" | ||
sudo -u postgres $NEWBIN/initdb -D "$NEWDATA" | ||
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-bindir $OLDBIN --new-bindir $NEWBIN \ | ||
--old-datadir "$OLDDATA" --new-datadir "$NEWDATA" \ | ||
"$@" | ||
'') | ||
sudo -u postgres $NEWBIN/pg_upgrade \ | ||
--old-bindir $OLDBIN --new-bindir $NEWBIN \ | ||
--old-datadir "$OLDDATA" --new-datadir "$NEWDATA" \ | ||
"$@" | ||
'' | ||
) | ||
]; | ||
} |