Merge: doc: use initdbArgs in example postgresql upgrade script (#302823)

This commit is contained in:
Maximilian Bosch 2024-09-29 20:39:05 +02:00 committed by GitHub
commit 0e78dc369c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -196,6 +196,7 @@ For an upgrade, a script like this can be used to simplify the process:
newPostgres = pkgs.postgresql_13.withPackages (pp: [
# pp.plv8
]);
cfg = config.services.postgresql;
in pkgs.writeScriptBin "upgrade-pg-cluster" ''
set -eux
# XXX it's perhaps advisable to stop all services that depend on postgresql
@ -205,12 +206,12 @@ For an upgrade, a script like this can be used to simplify the process:
export NEWBIN="${newPostgres}/bin"
export OLDDATA="${config.services.postgresql.dataDir}"
export OLDBIN="${config.services.postgresql.package}/bin"
export OLDDATA="${cfg.dataDir}"
export OLDBIN="${cfg.package}/bin"
install -d -m 0700 -o postgres -g postgres "$NEWDATA"
cd "$NEWDATA"
sudo -u postgres $NEWBIN/initdb -D "$NEWDATA"
sudo -u postgres $NEWBIN/initdb -D "$NEWDATA" ${builtins.concatStringsSep " " cfg.initdbArgs}
sudo -u postgres $NEWBIN/pg_upgrade \
--old-datadir "$OLDDATA" --new-datadir "$NEWDATA" \