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 1ixK4u-00078j-I4 for pgsql-general@arkaria.postgresql.org; Fri, 31 Jan 2020 00:22:33 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1ixK4s-0004K5-Es for pgsql-general@arkaria.postgresql.org; Fri, 31 Jan 2020 00:22:30 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ixK4q-0004Jq-LP for pgsql-general@lists.postgresql.org; Fri, 31 Jan 2020 00:22:30 +0000 Received: from out4-smtp.messagingengine.com ([66.111.4.28]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ixK4j-0003GV-EW for pgsql-general@postgresql.org; Fri, 31 Jan 2020 00:22:27 +0000 Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id 92C1821B2C; Thu, 30 Jan 2020 19:22:20 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute7.internal (MEProxy); Thu, 30 Jan 2020 19:22:20 -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=c CwmAIq8Abp+ceZOhQdn9JZYdk5xHUDGZp/yRECXDKk=; b=ANjaoIjvtlOw8Qq/6 v9czzBeEH8TS5b+WoZww9eBQRiABsb6j9uO80/GKQHpO8n5XhoUITfL9diAibM8N aE1W1Dbz4QTMJrU2jm1XQYs4ZKE66k0qdXUlc5oWY+2ZcXR0XDrt9w1KnDN/YlFV WVOcuqkGFzkJsza1NGQwV8/kRnuJsWAgvqKExRDDtrdPHeQmhSlX8VPNc1IQ7rC+ XHStPKb+PqllgQNLnp8nBYZAq8PjCfCXFx70CXhB8cFGOl3vD0EeZuQVe6LCYNQM I8ML3gB1goZBV99fFiFjcP8bCR+oNBcIzPx6cj313adF6eBvj80OasExnGTK+Luf S8l5w== 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=cCwmAIq8Abp+ceZOhQdn9JZYdk5xHUDGZp/yRECXD Kk=; b=ARKp/gPqrfKANUQFo4ffCnmp/AiY1Aov4vRQPmh1PGoVZJvSZcDx0Qezy K2ddecUZo3nyyZGsJQ/0Ors86kwxQros7gB3k98+Vpt216cDvS9z0fhXLAe1Mp3i XNAN4FFk+ipESJX/H9W92xGUl8PyE+jnTGw7YRBLttSVvGuOIC/fgoMHCHfiofNb SkvNrHhAhZxrWX9oWaUEd7h5NAgBSqYwGCOd5YkAPJt/fWeEsIC/4IUQ0bY6SyU7 yf/JowmL7NN91MJXKvkTReN9lGPydMuwnWhDSlUEsHQ1ZxSPvF1AZAvdH2WHjR8n 3Sv2SXNV7NN6xFFSc8Qe2fn50PZRA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedugedrfeelgddujecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhepuffvfhfhkffffgggjggtgfesthejre 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 C25253280063; Thu, 30 Jan 2020 19:22:19 -0500 (EST) Subject: Re: How to restore to empty database To: Andrus , pgsql-general References: <8f1d29bd-907e-e1c5-cc5f-2b9cade5af19@aklaver.com> <332CC5FE386B4B86AAE5556896A635ED@dell2> From: Adrian Klaver Message-ID: <8ac01396-cf14-0198-c49f-5f0bd298e544@aklaver.com> Date: Thu, 30 Jan 2020 16:22:18 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.2 MIME-Version: 1.0 In-Reply-To: <332CC5FE386B4B86AAE5556896A635ED@dell2> Content-Type: text/plain; charset=windows-1257; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 1/30/20 3:08 PM, Andrus wrote: > Hi! > >> You need to connect to a database that exists with --dbname, for >> instance --dbname=postgres. Postgres will then use that connection to >> create the new database, in your case mydb. > > Thank you, this seems work. > > There are total 24 databases, .backup files total size in 37GB , aprox 60 % > from this from bytea columns ( pdf documents, images). > Using VPS server, 4 cores, 11 GB RAM, used only for postgres. > Which is the fastest way to restore data from all of them to empty > databases. Should I run all commands in sequence like These days 37 GB is relatively small, so you maybe getting into the realm of premature optimization. Do the 24 databases represent an entire cluster you are trying to transfer? If so have you looked at pg_dumpall?: https://www.postgresql.org/docs/12/app-pg-dumpall.html It is a text based backup, but it will include all the databases and the globals. Otherwise I think you are going to find that the below will not make much difference given the overall size of the backup files. > > pg_restore --clean --create --if-exists --verbose --dbname=postgres > --jobs=4 > "database1.backup" > pg_restore --clean --create --if-exists --verbose --dbname=postgres > --jobs=4 > "database2.backup" > ... > pg_restore --clean --create --if-exists --verbose --dbname=postgres > --jobs=4 > "database24.backup" > > or run them all parallel without --jobs=4 like > > pg_restore --clean --create --if-exists --verbose --dbname=postgres > "database1.backup" & > pg_restore --clean --create --if-exists --verbose --dbname=postgres > "database2.backup" & > ... > pg_restore --clean --create --if-exists --verbose --dbname=postgres > --jobs=4 > "database24.backup" & > > > or some balance between those ? > Is there some postgres or Debian setting which can used during restore time > to speed up restore ? > I use shared_buffers=1GB , other settings from debian installation. > > Andrus. -- Adrian Klaver adrian.klaver@aklaver.com