From owner-freebsd-questions@FreeBSD.ORG Sun Dec 4 19:14:37 2011 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7B7AD106566C for ; Sun, 4 Dec 2011 19:14:37 +0000 (UTC) (envelope-from m.seaman@infracaninophile.co.uk) Received: from smtp.infracaninophile.co.uk (smtp6.infracaninophile.co.uk [IPv6:2001:8b0:151:1:3cd3:cd67:fafa:3d78]) by mx1.freebsd.org (Postfix) with ESMTP id EC1D68FC13 for ; Sun, 4 Dec 2011 19:14:36 +0000 (UTC) Received: from seedling.black-earth.co.uk (seedling.black-earth.co.uk [IPv6:2001:8b0:151:1:fa1e:dfff:feda:c0bb]) (authenticated bits=0) by smtp.infracaninophile.co.uk (8.14.5/8.14.5) with ESMTP id pB4JDiMe022211 (version=TLSv1/SSLv3 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO); Sun, 4 Dec 2011 19:13:45 GMT (envelope-from m.seaman@infracaninophile.co.uk) X-DKIM: OpenDKIM Filter v2.4.1 smtp.infracaninophile.co.uk pB4JDiMe022211 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=infracaninophile.co.uk; s=201001-infracaninophile; t=1323026025; bh=dT365xVh9l+qA4ks7m4qrhMxC18t0Q1cqNA9JNucNns=; h=Message-ID:Date:From:MIME-Version:To:CC:Subject:References: In-Reply-To:Content-Type; b=Ma+tYPT1FNjosoKCFufvAyJQzVmkP0JkVgxQhtvmsWG050i4N8Bdk54F6alTYxaW4 KNy1CEnq8/JzLUG25xap7tB4IkaVajjqdilMbaO+S0s0U9SBax7hBMHZtAbr0ixA6Z fVz5DYlBLSNE7BoKeiP19EGwEmCVwLV+fkzE4jKE= Message-ID: <4EDBC65F.8090106@infracaninophile.co.uk> Date: Sun, 04 Dec 2011 19:13:35 +0000 From: Matthew Seaman User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:8.0) Gecko/20111105 Thunderbird/8.0 MIME-Version: 1.0 To: Matthew Pounsett References: In-Reply-To: X-Enigmail-Version: 1.3.3 OpenPGP: id=60AE908C Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enigC950074FFE19187C53DBD3D4" X-Virus-Scanned: clamav-milter 0.97.3 at lucid-nonsense.infracaninophile.co.uk X-Virus-Status: Clean X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_FAIL autolearn=no version=3.3.2 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on lucid-nonsense.infracaninophile.co.uk Cc: Sergio Tam , freebsd-questions@freebsd.org Subject: Re: Major version changes using portupgrade? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 04 Dec 2011 19:14:37 -0000 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigC950074FFE19187C53DBD3D4 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On 04/12/2011 17:16, Matthew Pounsett wrote: > On 2011/12/04, at 02:29, Sergio Tam wrote: >=20 >>> >> =3D=3D=3D> postgresql-client-9.1.1_1 conflicts with installed pac= kage(s): >>> >> postgresql-client-8.4.8 >>> >>=20 >>> >> They will not build together. >>> >> Please remove them first with pkg_delete(1). <--------------= --pay attention here >>> >> *** Error code 1 >> >=20 >> >=20 >> > postgresql-client-8.4.8 >> >=20 >> > make deinstall > That's the ports makefiles talking, isn't it? In order to do that > deinstall I need to also remove all of the things that depend on > it... portupgrade is supposed to help me do the in-place upgrade > without removing everything else first. >=20 > Even if I forced the deinstall without letting the dependencies get > in the way, wouldn't that break the dependency registration > (+REQUIRED_BY) for all of those packages in the future? Yes. I've been planning a very similar update -- postgresql 9.0 to 9.1 -- and what I've come up with so far is this: 0) Backup *everything* 1) Stop postgresql daemon and any services that depend on postgresql 2) Move the postgresql data directory aside: # mv ~pgsql/data ~pgsql/data-9.0.5 3) Optional. If you have WITH_PGSQL_VER defined in /etc/make.conf, or similar update it at this point. Or delete it -- ports will pick up the new version automatically once you've updated to it. 4) Now for the updating bit. I'm going to use portmaster's '-o' functionality to swap out the postgresql versions. (portupgrade has very similar functionality if you prefer that.) postgresql is trickier than most, because there have to be both -server and -client ports to deal with. I also have postgresql-contrib-9.0.5 installed, which isn't critical but needs similar treatment. Everything depends on the -client port, so we start with that: # portmaster -o databases/postgresql91-client \ postgresql-client-9.0.5 # portmaster -o databases/postgresql91-server \ postgresql-server-9.0.5_1 # portmaster -o databases/postgresql91-contrib \ postgresql-contrib-9.0.5 5) Now rebuild everything that depends on the new postgresql client port. Use '-x' and '-R' to avoid rebuilding the ports already updated # portmaster -R -r postgresql-client-9.1.1_1 \ -x postgresql-server-9.1.1_1 -x postgresql-contrib-9.1.1_1 6) Re-init the postgresql cluster # su - pgsql % mkdir ~/data % initdb -D ~/data -E utf8 --locale C (or use the rc.d script) % vi ~/data/postgresql.conf (etc...) 7) Restart the postgresql database # /usr/local/etc/rc.d/postgresql start 8) Reload databases from backup. Restart all dependent services. 9) ??? 10) Profit! This does require an appreciable period of system downtime, but as that's fine for my purposes, I haven't put any effort into thinking about how to minimize that. A good thing to do if downtime is a big deal for you would be to build updated packages of everything postgresql related off-line and use portmaster's '-P' package mode to install them. Similarly, make backup packages of everything you're updating (pkg_create -b pkgname) so if you need to back everything out you can just swap those packages back in rather than doing a full-scale recovery from backup. Using this method for a very big database is not amazingly practical -- in that case, using pg_upgrade(8) would probably be preferable, but that's not going to entirely simple given the constraints of the ports system. You'll need to have both the previous and target versions of the postgresql-client and postgresql-contrib installed simultaneously, but those ports all conflict with each other. You'll also need to have two separate data directories -- the original one and one for the new version. The default layout on Linux nowadays includes the postgresql major version in the data directory path and in the names of most conflicting applications, but this capability hasn't come to the ports ye= t. Cheers, Matthew --=20 Dr Matthew J Seaman MA, D.Phil. 7 Priory Courtyard Flat 3 PGP: http://www.infracaninophile.co.uk/pgpkey Ramsgate JID: matthew@infracaninophile.co.uk Kent, CT11 9PW --------------enigC950074FFE19187C53DBD3D4 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.0.16 (Darwin) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk7bxmcACgkQ8Mjk52CukIwCDQCggPIFXvpE6lI7tyz/9VBclgyM LjIAni0ggHDLkmfxClC2qJ9beu0PHDKk =G+ey -----END PGP SIGNATURE----- --------------enigC950074FFE19187C53DBD3D4--