Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ivtEs-00042R-Gd for pgsql-general@arkaria.postgresql.org; Mon, 27 Jan 2020 01:30:54 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1ivtEq-0002Bx-N1 for pgsql-general@arkaria.postgresql.org; Mon, 27 Jan 2020 01:30:52 +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_SHA1:256) (Exim 4.89) (envelope-from ) id 1ivtEp-0002Bq-Ft for pgsql-general@lists.postgresql.org; Mon, 27 Jan 2020 01:30:52 +0000 Received: from wout3-smtp.messagingengine.com ([64.147.123.19]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ivtEl-0008OC-Ec for pgsql-general@postgresql.org; Mon, 27 Jan 2020 01:30:50 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id ACB76401; Sun, 26 Jan 2020 20:30:43 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Sun, 26 Jan 2020 20:30:43 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= subject:to:references:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=fm2; bh=F 4F9ePx1C4wQ4mcMqtsPzq7UdITaOo69OpxYllMoyCc=; b=FgFL5KTukqctwpbnL W9GU3NqiT+8aS9yc/sWgMudKi4yxCq3qjP5ee5xBipMcEdChfLgEIodWRd8XNB6p 9Zpz4d4jRNUxT+Mf2a/yacGCN+9Agw5lPLOG3Gbn50py3zdqp8q6Hw+NuW4V/iJ9 gMmUl6MxnlSpoBKp57XPeilkI0hsBdmO5lm3ne+v3x0iWqT6ufjXHUSjxYs7ucon yHbrf1wm/RrmOxWWNqXlGv9nsyLChKtDZ0hgURHGuAK23WVc3uO+NoTVWrlMFNGv NtvtHCoSrvCt70jD7RY5zeSKlRTr/WKjlwabTmxGEOid2WoEBVq+6XD7FOdncN4E TJJeA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=F4F9ePx1C4wQ4mcMqtsPzq7UdITaOo69OpxYllMoy Cc=; b=fLR9fGZHz/vGL28LzTt4RoNaEuScLonlmNVfrY67EkQu29guG+TRqKM6x j4ku7xBJZrLphK/9LKcowV8WLkwQLNm4KaTv70OXOClv225oly3DgQlsxSyyhkEX C/l3euUSQYaWfHdpinqgC75helgJ//I9IXlFNrcljcc2KkBEuTH8edzxFMjRmaib uhu5S0km/a8x4ANtDaIv61hIVtz8uHkYDQ8Y/gpzb7VNsWzlVjYmcM9QsASF4zGe UYt57UFQwXxo2Di4kdH4EwGMWTEOqncrWoBltBLEJzARC6f84axfnOvA09Q1dqpQ Qw/Jt5WZKUfFPNcGmEB6Uh6OArciA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedugedrfedugdefgecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhepuffvfhfhkffffgggjggtgfesthekre dttdefhhenucfhrhhomheptegurhhirghnucfmlhgrvhgvrhcuoegrughrihgrnhdrkhhl rghvvghrsegrkhhlrghvvghrrdgtohhmqeenucffohhmrghinhepphhoshhtghhrvghsqh hlrdhorhhgnecukfhppeejuddrvdduvddruddvledrudelfeenucevlhhushhtvghrufhi iigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrughrihgrnhdrkhhlrghvvghrse grkhhlrghvvghrrdgtohhm X-ME-Proxy: Received: from [192.168.1.10] (unknown [71.212.129.193]) by mail.messagingengine.com (Postfix) with ESMTPA id 7A280328005E; Sun, 26 Jan 2020 20:30:42 -0500 (EST) Subject: Re: How to transfer databases form one server to other To: Andrus , pgsql-general References: <157139E4A01D436A859FB6612AE6BBD7@dell2> <1102fee1-eebe-dbe2-63a2-2120380bb2f8@aklaver.com> <111D51B7C5C64419810F09C229E1D917@dell2> From: Adrian Klaver Message-ID: <23417975-69b8-e273-2a58-c65beb16decf@aklaver.com> Date: Sun, 26 Jan 2020 17:30:41 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 In-Reply-To: <111D51B7C5C64419810F09C229E1D917@dell2> Content-Type: text/plain; charset=windows-1257; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 1/26/20 2:47 PM, Andrus wrote: > Hi! > >> Before you do any of this I would check the Release Notes for the >> first release of each major release. Prior to version 10 that would be >> X.X.x where X is a major release. For 10+ that is X.x.  I would also >> test the upgrade before doing it on your production setup. > > I want to create test transfer first, check applications work and after > that final transfer. > >> Best practice if you are going the dump/restore route is to use the >> pg_dump binary from the new server(12) to dump the old server(9.1) > > Postgres version 12 pg_dump probably cannot installed in old server > (Debian Squeeze 9). > Running pg_dump in new server probably takes much more time since data > is read from uncompressed form and dumping is time-consuming process. > (internet connection between those server is fast, SSH copy speed was > 800 Mbit (not 100 Mbit as I wrote), it took 5 minutes to copy 37 GB). Test it and see how slow/fast it is. > > There are also some hundred of Postgresql login and group roles in old > server used also in access rights in databases. > Those needs transferred also. pg_dumpall -g > globals.sql will get you the global information. See: https://www.postgresql.org/docs/12/app-pg-dumpall.html More comment inline below. > > My plan is: > > 1. Use pg_dump 9.1 in old server to create 24 .backup files in custom > format. > 2. Use pgAdmin "backup globals" command to dump role definitions is old > server to text file. > 3. Manually edit role definitions to delete role postgres since it > exists in new server. No need, it will throw a harmless error message and continue on. > 4. Run edited role definitons script using pgadmin in new server to > create roles > 5. Use Midnight Commander to copy 24 .backup files from old to new server > 6. Use Postgres 12 pg_restore with job count 4 to restore  those 24 > databases to new server sequentially. > > To repeat transfer after testing: > > 1. Delete restored databases. > 2. Delete imported roles in new server That will probaly not end well. I'm guessing there are objects that have a dependency on the the roles. From you questions above and below I would say you need to set up a test bed and try an dump/restore on a single database. That will help focus you on the actual problems. I'm guessing there will be more then you have mentioned so far. > 3. Proceed 1-6 from plan again. > > > Questions: > > 1. pgAdmin allows only deletion roles one by one. > Deleting hundreds of roles is huge work. > How to invoke command like > > DELETE ALL ROLES EXCEPT postgres > > ? > Is there some command, script or pgadmin GUI for this ? > > 2. Is it OK to restore from 9.1 backups or should I create backups using > pg_dump from Postgres 12 ? > I have done some minor testing and havent found issues. > > 3. How to create shell script which reads all files from /root/backup > directory from old server? > (I'm new to linux, this is not postgresql related question) > > 4. Are there some settings which can used to speed up restore process ? > Will turning fsync off during restore speed up it ? > New server has 11 GB ram . No other applications are running during > database transfer. > shared_buffer=1GB setting is currently used in postgresql.conf > > 5. Can this plan improved > > Andrus. > > > -- Adrian Klaver adrian.klaver@aklaver.com