Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qvc36-006EoT-NM for pgsql-admin@arkaria.postgresql.org; Wed, 25 Oct 2023 11:27:44 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1qvc35-002c5A-AL for pgsql-admin@arkaria.postgresql.org; Wed, 25 Oct 2023 11:27:43 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qvc34-002c2f-Lx for pgsql-admin@lists.postgresql.org; Wed, 25 Oct 2023 11:27:42 +0000 Received: from wout1-smtp.messagingengine.com ([64.147.123.24]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qvc31-002ESy-Sc for pgsql-admin@lists.postgresql.org; Wed, 25 Oct 2023 11:27:41 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id 471C53200ACC; Wed, 25 Oct 2023 07:27:38 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Wed, 25 Oct 2023 07:27:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1698233257; x= 1698319657; bh=XKGFJUme+EnA5qoZKFVRzCI4MQz70lDonnTJJ5aq0Vs=; b=l 16pJJ2MwRB9ly8nP+VAzLqhOB6KYVNdzE1kQMqkByvpnu0OYgdilPoyGRsETJkmq ebmqPMd9/IJoVOReuDYHoH9wyoSsbLKS0VILOL0v5icOKIM3vFQhBu/KTSNFbrF+ nPxdUkvMo3/VHpt9kWdNFCkqoFi71PrztbBhGIBEo3AiNzujVu7W1L/Ps/jBs15y jh2t9bCWMjDGhBxHjI+zE0EZiRQQbDP9Rekew2H4segg6lwYbSL7jozqEInYshZY MF9i2ur7b16lPlEF4ZEuWGNHspqkFlJrHKrgorH+AIwncCboWO5YaEdXxt2nrZMz Qkew7RWG+0JalQy6uNksQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrledtgdegtdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvvefukfggtggugfgjsehtkeertddttdejnecuhfhrohhmpeetlhhvrghr ohcujfgvrhhrvghrrgcuoegrlhhvhhgvrhhrvgesrghlvhhhrdhnohdqihhprdhorhhgqe enucggtffrrghtthgvrhhnpedvkedtffduffdtffffheffhfejjefhgfeiueeukeejkeff gfdufffhudffffeuveenucffohhmrghinhepvghnthgvrhhprhhishgvuggsrdgtohhmne cuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprghlvhhh vghrrhgvsegrlhhvhhdrnhhoqdhiphdrohhrgh X-ME-Proxy: Feedback-ID: ia2694551:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 25 Oct 2023 07:27:37 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alvh.no-ip.org; s=schmee; t=1698233250; bh=HUndyi73+XVqSahJyl7FwQRJxEuJAQZG2d0/oDkbxag=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=XJ8vxe6wS/+BLU5RS/7vi/mkQv+k5TYDkBVv1POPtssWS9dyGOggVTyj/+/IJdysd LVOveaeL/ubzJ5C01ZsZ64BviRxzyxSwjXKPg2+cC7Gz4yLt7I3Q719Y9opStieCf9 R22IMpDS9vjGzGEnSKbRrL3mZF7MXOrvpQh9ulWIJTpkkQJyuzuYKYDE2wbJaHb7so ghNa2RkrIWSPZLmHlJt1UZLRH1g7sHsXDtKX0DwB2nno3KzhNrVhLkcNIslChwJjKP uRg/J0qprvCpcoG557vMQmoMwmR9Hb1nUKo9CXKDqhBo49hCH75DmaE3voJgcPXl2W wctBavUj+dGrQ== Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id D3177E3; Wed, 25 Oct 2023 13:27:30 +0200 (CEST) Date: Wed, 25 Oct 2023 13:27:30 +0200 From: Alvaro Herrera To: Aditya D Cc: Ron , pgsql-admin@lists.postgresql.org Subject: Re: User/Roles, Owner, and privileges migration strategy Message-ID: <202310251127.fhwfz7o7wjio@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2023-Oct-24, Aditya D wrote: > Thanks a lot Holger and Ron for the reply and valuable inputs. AWS RDS or > any other PaaS PostgreSQL instances does not support Superuser and to avoid > multiple pg_dump statements from on-premises to PaaS, is there any > recommended way? > > Query the catalog tables and form the alter owner statements which will run > post pg_dump - - no owner or any other suggested method? I would do this using the following steps: 1. take a "pg_dumpall -g". 2. take a pg_dump (in -Fc or -Fd mode) of each database to migrate. Do not use "--no-owner" or anything that breaks or incompletely dumps the ownership or ACLs or objects. 3. write a script to filter each of the dumps in step 2, to obtain the list of roles needed in GRANT commands or as object owners. 4. Filter the dump produced by step 1 down to the creation of just the roles obtained by step 3. 5. Restore each of the dumps from step 2. If step 5 finishes cleanly, then you're done. If it throws errors about ownership or GRANTs, then your filtering scripts in steps 3 or 4 have some mistake. Go back and fix the script, clean up from steps 4 and 5 and restart from 3. Lather, rinse, repeat. Note that you only need to dump each database exactly twice (first to produce the dumps you'll test with, second to do the actual migration once your filtering script for steps 3 and 4 have been perfected.) If you have objects owned by "postgres" or some other superuser, I'd change them ahead of time to something else. -- Álvaro Herrera Breisgau, Deutschland — https://www.EnterpriseDB.com/ "In fact, the basic problem with Perl 5's subroutines is that they're not crufty enough, so the cruft leaks out into user-defined code instead, by the Conservation of Cruft Principle." (Larry Wall, Apocalypse 6)