[pmg-devel] [RFC pmg-api 03/12] Restore: optionally restore from directory
Stoiko Ivanov
s.ivanov at proxmox.com
Mon Oct 19 21:02:00 CEST 2020
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 <s.ivanov at proxmox.com>
---
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
More information about the pmg-devel
mailing list