@@ -19,6 +19,7 @@ source /etc/hestiacp/hestia.conf
1919# load config file
2020source_conf " $HESTIA /conf/hestia.conf"
2121
22+ # Check required binaries
2223if [ ! -e /usr/bin/rsync ] || [ ! -e /usr/bin/file ]; then
2324 echo " #######################################"
2425 echo " rsync not installed, try install it"
@@ -31,6 +32,7 @@ if [ ! -e /usr/bin/rsync ] || [ ! -e /usr/bin/file ]; then
3132 fi
3233 exit 3
3334fi
35+
3436# Put this to 0 if you want use bash -x to debug it
3537debug=1
3638hestia_package=default
@@ -63,42 +65,79 @@ tput sgr0
6365tput setaf 2
6466echo " Checking provided file..."
6567tput sgr0
66- if file $backup_file | grep -q -c " gzip compressed data," ; then
68+
69+ if file " $backup_file " | grep -q -c " gzip compressed data" ; then
6770 tput setaf 2
68- echo " OK - Gziped File"
71+ echo " OK - Gzipped File"
6972 tput sgr0
73+
7074 if [ ! -d /backup/${tmp_dir} ]; then
71- echo " Creating tmp .."
75+ echo " Creating temporary directory. .."
7276 mkdir /backup/${tmp_dir}
7377 fi
78+
7479 echo " Extracting backup..."
7580 if [ " $debug " != 0 ]; then
76- tar xzvf $backup_file -C /backup/${tmp_dir} 2>&1 \
77- | while read extracted_file; do
78- ex=$(( ex + 1 ))
79- echo -en " wait... $ex files extracted\r"
80- done
81+ tar xzvf " $backup_file " -C /backup/${tmp_dir} 2>&1 | while read -r extracted_file; do
82+ ex=$(( ex + 1 ))
83+ echo -en " wait... $ex files extracted\r"
84+ done
85+ else
86+ tar xzf " $backup_file " -C /backup/${tmp_dir}
87+ fi
88+
89+ if [ $? -eq 0 ]; then
90+ tput setaf 2
91+ echo " Backup extracted without errors..."
92+ tput sgr0
93+ else
94+ tput setaf 1
95+ echo " Error on backup extraction, check your file and try extracting it manually"
96+ tput sgr0
97+ delete_tmp
98+ exit 1
99+ fi
100+
101+ elif file " $backup_file " | grep -q -c " Zstandard compressed data" ; then
102+ tput setaf 2
103+ echo " OK - Zstandard Compressed File"
104+ tput sgr0
105+
106+ if [ ! -d /backup/${tmp_dir} ]; then
107+ echo " Creating temporary directory..."
108+ mkdir /backup/${tmp_dir}
109+ fi
110+
111+ echo " Extracting backup..."
112+ if [ " $debug " != 0 ]; then
113+ tar --use-compress-program=pzstd -xvf " $backup_file " -C /backup/${tmp_dir} 2>&1 | while read -r extracted_file; do
114+ ex=$(( ex + 1 ))
115+ echo -en " wait... $ex files extracted\r"
116+ done
81117 else
82- tar xzf $backup_file -C /backup/${tmp_dir}
118+ tar --use-compress-program=pzstd -xf " $backup_file " -C /backup/${tmp_dir}
83119 fi
120+
84121 if [ $? -eq 0 ]; then
85122 tput setaf 2
86- echo " Backup extracted whitout errors..."
123+ echo " Backup extracted without errors..."
87124 tput sgr0
88125 else
89126 tput setaf 1
90- echo " Error on backup extraction, check your file, try extract it manually"
127+ echo " Error on backup extraction, check your file and try extracting it manually"
91128 tput sgr0
92129 delete_tmp
93130 exit 1
94131 fi
132+
95133else
96134 tput setaf 1
97- echo " Error 3 not-gzip - no standard gziped backup provided of file not installed ( Try yum install file, or apt-get install file )"
135+ echo " Error: Unsupported file format or ' file' command not installed (Try ' yum install file' or ' apt-get install file' )"
98136 tput sgr0
99137 delete_tmp
100138 exit 3
101139fi
140+
102141cd /backup/${tmp_dir} /
103142main_dir=$( pwd)
104143echo " Access tmp directory $main_dir "
0 commit comments