From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id D728C63D49 for ; Wed, 28 Oct 2020 19:55:24 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id C424622A93 for ; Wed, 28 Oct 2020 19:54:51 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [212.186.127.180]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 5436B229E1 for ; Wed, 28 Oct 2020 19:54:48 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 11A6945F95 for ; Wed, 28 Oct 2020 19:54:48 +0100 (CET) From: Stoiko Ivanov To: pmg-devel@pve.proxmox.com Date: Wed, 28 Oct 2020 19:54:21 +0100 Message-Id: <20201028185432.23067-6-s.ivanov@proxmox.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201028185432.23067-1-s.ivanov@proxmox.com> References: <20201028185432.23067-1-s.ivanov@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.286 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [backup.pm] URIBL_SBL 0.644 Contains an URL's NS IP listed in the Spamhaus SBL blocklist [backup.pm] URIBL_SBL_A 0.1 Contains URL's A record listed in the Spamhaus SBL blocklist [backup.pm] Subject: [pmg-devel] [PATCH pmg-api 03/11] Restore: optionally restore from directory X-BeenThere: pmg-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Mail Gateway development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 Oct 2020 18:55:24 -0000 In preparation for integrating PMG with PBS decide based on the type of the provided filename, whether or not to untar: * if it's a directory skip untarring (PBS) * if it's a filename untar (local backup) Signed-off-by: Stoiko Ivanov --- src/PMG/Backup.pm | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/PMG/Backup.pm b/src/PMG/Backup.pm index 40c41f3..aec7905 100644 --- a/src/PMG/Backup.pm +++ b/src/PMG/Backup.pm @@ -245,12 +245,23 @@ sub pmg_restore { my $tarfn = "config_backup.tar"; my $sigfn = "proxmox_backup_v1.md5"; + my $untar = 1; + + # directory indicates that the files were restored from a PBS remote + if ( -d $filename ) { + $dirname = $filename; + $untar = 0; + } + eval { - # create a temporary directory - mkdir $dirname; - system("cd $dirname; tar xzf $filename >/dev/null 2>&1") == 0 || - die "unable to extract backup archive: ERROR"; + if ($untar) { + # create a temporary directory + mkdir $dirname; + + system("cd $dirname; tar xzf $filename >/dev/null 2>&1") == 0 || + die "unable to extract backup archive: ERROR"; + } system("cd $dirname; md5sum -c $sigfn") == 0 || die "proxmox backup signature check failed: ERROR"; -- 2.20.1