.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` . ds C' 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "PG_UPGRADECLUSTER 1" .TH PG_UPGRADECLUSTER 1 2024-04-15 Debian "Debian PostgreSQL infrastructure" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH NAME pg_upgradecluster \- upgrade an existing PostgreSQL cluster to a new major version. .SH SYNOPSIS .IX Header "SYNOPSIS" \&\fBpg_upgradecluster\fR [\fB\-v\fR \fInewversion\fR] \fIoldversion\fR \fIname\fR [\fInewdatadir\fR] .SH DESCRIPTION .IX Header "DESCRIPTION" \&\fBpg_upgradecluster\fR upgrades an existing PostgreSQL server cluster (i. e. a collection of databases served by a \fBpostgres\fR instance) to a new version specified by \fInewversion\fR (default: latest available version). The configuration files of the old version are copied to the new cluster and adjusted for the new version. The new cluster is set up to use data page checksums if the old cluster uses them. .PP The cluster of the old version will be configured to use a previously unused port since the upgraded one will use the original port. The old cluster is not automatically removed. After upgrading, please verify that the new cluster indeed works as expected; if so, you should remove the old cluster with \&\fBpg_dropcluster\fR\|(8). Please note that the old cluster is set to "manual" startup mode, in order to avoid inadvertently changing it; this means that it will not be started automatically on system boot, and you have to use \&\fBpg_ctlcluster\fR\|(8) to start/stop it. See section "STARTUP CONTROL" in \&\fBpg_createcluster\fR\|(8) for details. .PP The \fInewdatadir\fR argument can be used to specify a non-default data directory of the upgraded cluster. It is passed to \fBpg_createcluster\fR. If not specified, this defaults to /var/lib/postgresql/\fInewversion\fR/\fIname\fR. .SH OPTIONS .IX Header "OPTIONS" .IP "\fB\-v\fR \fInewversion\fR" 4 .IX Item "-v newversion" Set the version to upgrade to (default: latest available). .IP "\fB\-\-logfile\fR \fIfilel\fR" 4 .IX Item "--logfile filel" Set a custom log file path for the upgraded database cluster. .IP \fB\-\-locale=\fR\fIlocale\fR 4 .IX Item "--locale=locale" Set the default locale for the upgraded database cluster. If this option is not specified, the locale is inherited from the old cluster. .Sp When upgrading to PostgreSQL 11 or newer, this option no longer allows switching the encoding of individual databases. (\fBpg_dumpall\fR\|(1) was changed to retain database encodings.) .IP \fB\-\-lc\-collate=\fR\fIlocale\fR 4 .IX Item "--lc-collate=locale" .PD 0 .IP \fB\-\-lc\-ctype=\fR\fIlocale\fR 4 .IX Item "--lc-ctype=locale" .IP \fB\-\-lc\-messages=\fR\fIlocale\fR 4 .IX Item "--lc-messages=locale" .IP \fB\-\-lc\-monetary=\fR\fIlocale\fR 4 .IX Item "--lc-monetary=locale" .IP \fB\-\-lc\-numeric=\fR\fIlocale\fR 4 .IX Item "--lc-numeric=locale" .IP \fB\-\-lc\-time=\fR\fIlocale\fR 4 .IX Item "--lc-time=locale" .PD Like \fB\-\-locale\fR, but only sets the locale in the specified category. .IP "\fB\-m\fR, \fB\-\-method=\fR\fBdump\fR|\fBupgrade\fR|\fBlink\fR|\fBclone\fR" 4 .IX Item "-m, --method=dump|upgrade|link|clone" Specify the upgrade method. \fBdump\fR uses \fBpg_dump\fR\|(1) and \&\fBpg_restore\fR\|(1), \fBupgrade\fR uses \fBpg_upgrade\fR\|(1). The default is \&\fBdump\fR. .Sp \&\fBlink\fR and \fBclone\fR are shorthands for \fB\-m upgrade \-\-link\fR and \fB\-m upgrade \-\-clone\fR, respectively. .IP "\fB\-k\fR, \fB\-\-link\fR" 4 .IX Item "-k, --link" In pg_upgrade mode, use hard links instead of copying files to the new cluster. This option is merely passed on to pg_upgrade. See \&\fBpg_upgrade\fR\|(1) for details. .IP \fB\-\-clone\fR 4 .IX Item "--clone" In pg_upgrade mode, use efficient file cloning (also known as "reflinks" on some systems) instead of copying files to the new cluster. This option is merely passed on to pg_upgrade. See \fBpg_upgrade\fR\|(1) for details. .IP "\fB\-j\fR, \fB\-\-jobs\fR" 4 .IX Item "-j, --jobs" In pg_upgrade mode, number of simultaneous processes to use. This option is passed on to pg_upgrade. See \fBpg_upgrade\fR\|(1) for details. It is also used by the \fBanalyze\fR upgrade hook (via the \fBPGJOBS\fR environment variable). .IP \fB\-\-keep\-port\fR 4 .IX Item "--keep-port" By default, the old cluster is moved to a new port, and the new cluster is moved to the original port so clients will see the upgraded cluster. This option disables that. .IP "\fB\-\-rename=\fR\fInew cluster name\fR" 4 .IX Item "--rename=new cluster name" Use a different name for the upgraded cluster. .IP \fB\-\-old\-bindir=\fR\fIdirectory\fR 4 .IX Item "--old-bindir=directory" Passed to \fBpg_upgrade\fR. .IP \fB\-\-maintenance\-db=\fR\fIdatabase\fR 4 .IX Item "--maintenance-db=database" Database to connect to for maintenance queries. The default is \fBtemplate1\fR. .IP \fB\-\-[no\-]start\fR 4 .IX Item "--[no-]start" Start the new database cluster after upgrading. The default is to start the new cluster if the old cluster was running, or if upgrade hook scripts are present. .IP \fB\-\-keep\-on\-error\fR 4 .IX Item "--keep-on-error" If upgrading fails, the newly created cluster is removed. This option disables that. .SH "HOOK SCRIPTS" .IX Header "HOOK SCRIPTS" Some PostgreSQL extensions like PostGIS need metadata in auxiliary tables which must not be upgraded from the old version, but rather initialized for the new version before copying the table data. For this purpose, extensions (as well as administrators, of course) can drop upgrade hook scripts into \&\f(CW\*(C`/etc/postgresql\-common/pg_upgradecluster.d/\*(C'\fR. Script file names must consist entirely of upper and lower case letters, digits, underscores, and hyphens; in particular, dots (i. e. file extensions) are not allowed. .PP Scripts in that directory will be called with the following arguments: .PP .PP Phases: .IP \fBinit\fR 4 .IX Item "init" A virgin cluster of version \fInew version\fR has been created, i. e. this new cluster will already have \fBtemplate1\fR and \fBpostgres\fR, but no user databases. Please note that you should not create tables in this phase, since they will be overwritten by the dump/restore or \fBpg_upgrade\fR operation. .IP \fBfinish\fR 4 .IX Item "finish" All data from the old version cluster has been dumped/reloaded into the new one. The old cluster still exists, but is not running. .PP Failing scripts will abort the upgrade. The scripts are called as the user who owns the database. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fBpg_createcluster\fR\|(8), \fBpg_dropcluster\fR\|(8), \fBpg_lsclusters\fR\|(1), \fBpg_wrapper\fR\|(1) .SH AUTHORS .IX Header "AUTHORS" Martin Pitt , Christoph Berg