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 04FBF60DC9 for ; Mon, 19 Oct 2020 21:02:29 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 02DBE2F1C1 for ; Mon, 19 Oct 2020 21:02:29 +0200 (CEST) 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 B94D42F143 for ; Mon, 19 Oct 2020 21:02:23 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 893C8444A5 for ; Mon, 19 Oct 2020 21:02:23 +0200 (CEST) From: Stoiko Ivanov To: pmg-devel@lists.proxmox.com Date: Mon, 19 Oct 2020 21:02:00 +0200 Message-Id: <20201019190209.11495-4-s.ivanov@proxmox.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201019190209.11495-1-s.ivanov@proxmox.com> References: <20201019190209.11495-1-s.ivanov@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.306 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_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] [RFC pmg-api 03/12] 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: Mon, 19 Oct 2020 19:02:29 -0000 In preparation for integrating PMG with PBS decided 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 3854a5d..fd7274c 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