Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l2xJk-0002o6-2g for pgsql-general@arkaria.postgresql.org; Fri, 22 Jan 2021 14:21:40 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1l2xJi-0006IX-TF for pgsql-general@arkaria.postgresql.org; Fri, 22 Jan 2021 14:21:38 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l2xJi-0006IQ-IW for pgsql-general@lists.postgresql.org; Fri, 22 Jan 2021 14:21:38 +0000 Received: from campbell-lange.net ([178.79.140.51]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l2xJe-0008Kk-Uv for pgsql-general@lists.postgresql.org; Fri, 22 Jan 2021 14:21:37 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=campbell-lange.net; s=it; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=jX0WFK1P7cU48ev2F3685/Xmb5ZmV4EZ3SO6P1LNTFs=; b=Ss7TS//ovKR+XugD6TbR8zZda 3agX/9g5lIhTRlZhtrvfbQFQOIvV7bzEOrDGa1no3ieL2xjcIl8M6qgnXmNnT6yf05qkOoqZ0n9TE 40dl5XZUVS6HsuU0Yy4ZSfBhkUQPmzjFhUq5KP+1MbSWaZYFD2fwU5MuAT757/LOraT/c=; Received: from [217.138.52.158] (helo=rory-t470s) by campbell-lange.net with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l2xJd-000211-39; Fri, 22 Jan 2021 14:21:33 +0000 Received: from rory by rory-t470s with local (Exim 4.92) (envelope-from ) id 1l2xJc-0002oz-U0; Fri, 22 Jan 2021 14:21:32 +0000 Date: Fri, 22 Jan 2021 14:21:32 +0000 From: Rory Campbell-Lange To: sivapostgres@yahoo.com Cc: Ken Tanzer , pgsql-general , Ray O'Donnell , Benedict Holland Subject: Re: Copy & Re-copy of DB Message-ID: <20210122142132.GA10505@campbell-lange.net> References: <1776022013.3890342.1611234824367.ref@mail.yahoo.com> <1776022013.3890342.1611234824367@mail.yahoo.com> <00b51766-0fb1-6c6c-82c1-e08cf122e798@rodonnell.ie> <1829358841.3898628.1611237155653@mail.yahoo.com> <132794689.1264279.1611299517588@mail.yahoo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 22/01/21, Benedict Holland (benedict.m.holland@gmail.com) wrote: > I mean... the best? You just laid out a bunch of steps to define a process. > > > On Thu, Jan 21, 2021 at 11:12 PM sivapostgres@yahoo.com < > > sivapostgres@yahoo.com> wrote: > > > >> So the solution to the issue will be > >> > >> 1. Backup a DB using PGDUMP from 1st server. > >> 2. Restore the DB in 2nd server. > >> 3. Make required changes in the 2nd server. > >> 4. Backup that DB using PGDUMP from 2nd server. > >> 5. Delete / Rename that DB in the 1st server > >> 6. Restore that DB in the 1st server. > >> 7. Work again in the 1st server. > >> > >> Is this the best way to carry out this process? Rather late to the party, and I expect this has been mentioned already, but presumably changes to any database are either to do with the data or to do with aspects such as the pl functions. Data transformations can be tested in production and testing in transactions, so that the logic of the transformation can be captured in a set of SQL statements which can be applied to either environment through a (possibly automated) revision control system. Data insertions are much more conveniently only done on the production database, as converging data between different databases can be tricky. However if your data is conveniently added in bulk without the risk of duplication, a revision control approach could also work. Finally working on pl functions and similar changes we do out of revision control. In other words, "if it works in testing we apply it to production". Of the the three only this is idempotent. In any event, perhaps the following could work? 1. Backup the DB on the 1st server using pg_dump 2. Restore the DB on the 2nd server 3. Record changes on the 2nd server as revision controlled statements 4. Replay changes on the 1st server using the revision controlled statements Regards Rory