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 1jv8xe-0000jI-0v for pgsql-general@arkaria.postgresql.org; Tue, 14 Jul 2020 00:38:18 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jv8xc-0001gY-LW for pgsql-general@arkaria.postgresql.org; Tue, 14 Jul 2020 00:38:16 +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 1jv8xa-0001gR-Ma for pgsql-general@lists.postgresql.org; Tue, 14 Jul 2020 00:38:16 +0000 Received: from [66.111.4.28] (helo=out4-smtp.messagingengine.com) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jv8xW-0001GH-FZ for pgsql-general@lists.postgresql.org; Tue, 14 Jul 2020 00:38:13 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id C046C5C01F5; Mon, 13 Jul 2020 20:37:58 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Mon, 13 Jul 2020 20:37:58 -0400 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=fm3; bh=3 s0xJluoOnXWcla34wujCNA1pr1SgPBjYmzJSTHzNOE=; b=ZEaGnddJ06AUeMiEO 28C5flLEYAdEMk5A62Xre6/Oh/jrnE1UiUzYJ1FqSjV7EBlCOZT8eMzuvmazjG6S ShtQlsH/+NenlZkEOBQ+J7L9P2AAEneBsbPtFY0YCqCRdNsWAeY6Qdi7XJu3NAL/ SAiUsfT0wgevNtuX21+7gZ8QI6PrYLpBTb/Ebt8brQ5hRdWqte89fTWsZgMlULuE pyT1FNLgrgvDpAsO956nFdfCuGyUq0PqDhuI0NmldRdNM22sQGJJVph+9AizyIM/ lYEh+h89wiPHSzzeEjB1t+t+SKZjKkOg3EroJUr+cBaBV3drvxgmENIfBqnuwwwB K0gBA== 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=fm3; bh=3s0xJluoOnXWcla34wujCNA1pr1SgPBjYmzJSTHzN OE=; b=L1/USjzkfTdCfNciogwgC+aCOTgYd1lqtnHeu4Z4nZK/zz0oint1l4MxO PAd+S8V6x03DcgpRtmtDp1k55hHniQ+RwHUbPi9/+zGtPZtvc8ZAAlxvW2Hz744O 3n/yXCuUOjAxumvZxsRKWauSUoDLlmp65THiDv29idcCs+J4e5cp0L+eIeUv+QUK YMxAV8UQ++v4imVpxHfkevTbqLBhVbVYcNT/v83DgJ/MnYFkwfs+pLf8rJ7FAKrr 76B5JOwlGgni6uGZNzZ/t5CRZlKpZr2sh72+de5i/0Kpno/R45RHjarYrz2PZNmD fHqq4e11bEjJRL0JgoGojeTnAfYIA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrvdelgdefgecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhepuffvfhfhkffffgggjggtgfesthekre dttdefjeenucfhrhhomheptegurhhirghnucfmlhgrvhgvrhcuoegrughrihgrnhdrkhhl rghvvghrsegrkhhlrghvvghrrdgtohhmqeenucggtffrrghtthgvrhhnpeevveefveefue egffekkefhgeeiueffgfetueejvdfghfeujeejhfekjeelgedtgeenucfkphepjeehrddu jedvrdehrddvfedunecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilh hfrhhomheprggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtghomh X-ME-Proxy: Received: from [192.168.1.3] (75-172-5-231.tukw.qwest.net [75.172.5.231]) by mail.messagingengine.com (Postfix) with ESMTPA id F0DBA3060067; Mon, 13 Jul 2020 20:37:57 -0400 (EDT) Subject: Re: backup -restore question To: Ron , pgsql-general@lists.postgresql.org References: <97dbd799-7a6c-d0bc-deb2-fd56d3cda7a9@aklaver.com> <4e073ca3-9813-0fdb-a31e-4bb55efd4dd5@gmail.com> From: Adrian Klaver Message-ID: <6ce138d2-0b27-30ab-5da0-6c9cc0bb69fe@aklaver.com> Date: Mon, 13 Jul 2020 17:37:57 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <4e073ca3-9813-0fdb-a31e-4bb55efd4dd5@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Host-Lookup-Failed: Reverse DNS lookup failed for 66.111.4.28 (deferred) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 7/13/20 2:56 PM, Ron wrote: > On 7/13/20 2:32 PM, Adrian Klaver wrote: >> On 7/13/20 12:12 PM, Julie Nishimura wrote: >>> Hello there, >>> One of our PostgreSQL 9.4.1  databases has been backed up as *.gz >>> file with the compression 9 "pg_dump -Z 9". What is the right format >>> of restore this file when needed? Can I run the restore from a >>> compressed file or I need to unzip the file first, then run >>> pg_restore? Thanks >> >> It depends on whether you dumped using the custom format -Fc or >> plain(no -F or -Fp). If the custom format then you run pg_restore >> against it. If the plain format then you will to unzip first then feed >> the file to psql. > > What about this? > gunzip -c | foo.sql.gz | psql > gunzip -c | test_plain.gz | psql -d test_gz -U postgres bash: test_plain.gz: command not found gzip: compressed data not read from a terminal. Use -f to force decompression. For help, type: gzip -h Null display is "NULL". I think what you want is: gunzip -c test_plain.gz | psql -d test_gz -U postgres Null display is "NULL". SET SET SET SET SET set_config ------------ (1 row) SET SET SET SET CREATE SCHEMA .... In any case that will only work if the *.gz file is a compressed plain text format. My suspicion is it is, still I had to allow the possibility that it is a custom format file that someone hung a gz extension on. -- Adrian Klaver adrian.klaver@aklaver.com