Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eelc3-0003Yr-C3 for pgsql-docs@arkaria.postgresql.org; Thu, 25 Jan 2018 17:46:59 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eelc2-0007Xo-PZ for pgsql-docs@arkaria.postgresql.org; Thu, 25 Jan 2018 17:46:58 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1eelc2-0007Xe-Jc for pgsql-docs@lists.postgresql.org; Thu, 25 Jan 2018 17:46:58 +0000 Received: from momjian.us ([72.94.173.45]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1eelbz-0003AE-6d for pgsql-docs@lists.postgresql.org; Thu, 25 Jan 2018 17:46:58 +0000 Received: from bruce by momjian.us with local (Exim 4.84_2) (envelope-from ) id 1eelbw-0002pW-ED; Thu, 25 Jan 2018 12:46:52 -0500 Date: Thu, 25 Jan 2018 12:46:52 -0500 From: Bruce Momjian To: Don Seiler Cc: pgsql-docs@lists.postgresql.org Subject: Re: Bug in pg_upgrade standby rsync doc Message-ID: <20180125174652.GA3162@momjian.us> References: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="2oS5YaxWCcQjTEyO" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --2oS5YaxWCcQjTEyO Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit On Thu, Dec 7, 2017 at 11:28:12AM -0600, Don Seiler wrote: > In step 10 of the pg_upgrade doc at https://www.postgresql.org/docs/9.6/static/ > pgupgrade.html, it uses this example for rsyncing the main $PGDATA dir to the > standby: > > > rsync --archive --delete --hard-links --size-only --no-inc-recursive /opt/PostgreSQL/9.5/data \ > /opt/PostgreSQL/9.6/data standby.example.com:/opt/PostgreSQL > > > However when I ran this (substituting /var/lib/pgsql for /opt/PostgreSQL), I > found that it put a directory under /var/lib/pgsql/data, and my 9.6/data dir > was still empty. Furthermore, what was in /var/lib/pgsql/data appeared to be > the old 9.2 contents. > > I suspect this is because the "data" directories are two levels below the > parent directory specified at the end of the command. When I used the similar > command for separate tablespaces, it worked as expected. > > When I run the command with the "data" dir, so that I'm just specifying 9.2 and > 9.6, it works as desired. eg: > > > rsync --archive --delete --hard-links --size-only --no-inc-recursive /opt/PostgreSQL/9.5 \ > /opt/PostgreSQL/9.6 standby.example.com:/opt/PostgreSQL > > > FWIW I was upgrading from 9.2.22 to 9.6.6 on CentOS 6. Sorry I am just getting to this. I was able to reproduce your results with rsync version 3.1.1. With /opt/PostgreSQL containing: /opt/PostgreSQL /opt/PostgreSQL/9.5 /opt/PostgreSQL/9.5/data /opt/PostgreSQL/9.5/data/x /opt/PostgreSQL/9.6 /opt/PostgreSQL/9.6/data /opt/PostgreSQL/9.6/data/y This script: TMP="/tmp" rm -rf $TMP/PostgreSQL mkdir -p $TMP/PostgreSQL/9.5/data mkdir -p $TMP/PostgreSQL/9.6/data rsync --archive --delete --hard-links --size-only \ --no-inc-recursive /opt/PostgreSQL/9.5 \ /opt/PostgreSQL/9.6 $TMP/PostgreSQL find $TMP/PostgreSQL -print Yields: /tmp/PostgreSQL /tmp/PostgreSQL/9.5 /tmp/PostgreSQL/9.5/data --> /tmp/PostgreSQL/9.5/data/x /tmp/PostgreSQL/9.6 /tmp/PostgreSQL/9.6/data --> /tmp/PostgreSQL/9.6/data/y which is correct, but if I change rsync to match our docs: rsync --archive --delete --hard-links --size-only \ --no-inc-recursive /opt/PostgreSQL/9.5/data \ /opt/PostgreSQL/9.6/data $TMP/PostgreSQL I get: /rtmp/PostgreSQL /rtmp/PostgreSQL/9.5 /rtmp/PostgreSQL/9.5/data /rtmp/PostgreSQL/9.6 /rtmp/PostgreSQL/9.6/data --> /rtmp/PostgreSQL/data --> /rtmp/PostgreSQL/data/x --> /rtmp/PostgreSQL/data/y which is incorrect and the behavior you reported. The incorrect example was added a few months ago: commit 9521ce4a7a1125385fb4de9689f345db594c516a Author: Bruce Momjian Date: Wed Sep 13 09:11:28 2017 -0400 docs: improve pg_upgrade standby instructions This makes it clear that pg_upgrade standby upgrade instructions should only be used in link mode, adds examples, and explains how rsync works with links. Reported-by: Andreas Joseph Krogh Discussion: https://postgr.es/m/VisenaEmail.6c.c0e592c5af4ef0a2.15e785dcb61@tc7-visena Backpatch-through: 9.5 but the generic syntax mentioning the data directory has been there for a while. I am wondering if people had to test this to get it working and didn't report that saying datadir was inaccurate. I propse the attached patch to fix the generic syntax and the example. I will backpatch it through 9.5. As you stated, the tablespace example is fine. -- Bruce Momjian http://momjian.us EnterpriseDB http://enterprisedb.com + As you are, so once was I. As I am, so you will be. + + Ancient Roman grave inscription + --2oS5YaxWCcQjTEyO Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="rsync.diff" diff --git a/doc/src/sgml/ref/pgupgrade.sgml b/doc/src/sgml/ref/pgupgrade.sgml new file mode 100644 index 055eac3..baf67db *** a/doc/src/sgml/ref/pgupgrade.sgml --- b/doc/src/sgml/ref/pgupgrade.sgml *************** pg_upgrade.exe *** 494,503 **** server: ! rsync --archive --delete --hard-links --size-only --no-inc-recursive old_pgdata new_pgdata remote_dir ! where and are relative to the current directory on the primary, and is above the old and new cluster directories on the standby. The directory structure under the specified --- 494,503 ---- server: ! rsync --archive --delete --hard-links --size-only --no-inc-recursive old_cluster new_cluster remote_dir ! where and are relative to the current directory on the primary, and is above the old and new cluster directories on the standby. The directory structure under the specified *************** rsync --archive --delete --hard-links -- *** 506,513 **** remote directory, e.g. ! rsync --archive --delete --hard-links --size-only --no-inc-recursive /opt/PostgreSQL/9.5/data \ ! /opt/PostgreSQL/9.6/data standby.example.com:/opt/PostgreSQL You can verify what the command will do using --- 506,513 ---- remote directory, e.g. ! rsync --archive --delete --hard-links --size-only --no-inc-recursive /opt/PostgreSQL/9.5 \ ! /opt/PostgreSQL/9.6 standby.example.com:/opt/PostgreSQL You can verify what the command will do using --2oS5YaxWCcQjTEyO--