|
|
@@ -19,6 +19,7 @@ source /etc/hestiacp/hestia.conf
|
|
|
# load config file
|
|
|
source_conf "$HESTIA/conf/hestia.conf"
|
|
|
|
|
|
+# Check required binaries
|
|
|
if [ ! -e /usr/bin/rsync ] || [ ! -e /usr/bin/file ]; then
|
|
|
echo "#######################################"
|
|
|
echo "rsync not installed, try install it"
|
|
|
@@ -31,6 +32,7 @@ if [ ! -e /usr/bin/rsync ] || [ ! -e /usr/bin/file ]; then
|
|
|
fi
|
|
|
exit 3
|
|
|
fi
|
|
|
+
|
|
|
# Put this to 0 if you want use bash -x to debug it
|
|
|
debug=1
|
|
|
hestia_package=default
|
|
|
@@ -63,42 +65,79 @@ tput sgr0
|
|
|
tput setaf 2
|
|
|
echo "Checking provided file..."
|
|
|
tput sgr0
|
|
|
-if file $backup_file | grep -q -c "gzip compressed data,"; then
|
|
|
+
|
|
|
+if file "$backup_file" | grep -q -c "gzip compressed data"; then
|
|
|
tput setaf 2
|
|
|
- echo "OK - Gziped File"
|
|
|
+ echo "OK - Gzipped File"
|
|
|
tput sgr0
|
|
|
+
|
|
|
if [ ! -d /backup/${tmp_dir} ]; then
|
|
|
- echo "Creating tmp.."
|
|
|
+ echo "Creating temporary directory..."
|
|
|
mkdir /backup/${tmp_dir}
|
|
|
fi
|
|
|
+
|
|
|
echo "Extracting backup..."
|
|
|
if [ "$debug" != 0 ]; then
|
|
|
- tar xzvf $backup_file -C /backup/${tmp_dir} 2>&1 \
|
|
|
- | while read extracted_file; do
|
|
|
- ex=$((ex + 1))
|
|
|
- echo -en "wait... $ex files extracted\r"
|
|
|
- done
|
|
|
+ tar xzvf "$backup_file" -C /backup/${tmp_dir} 2>&1 | while read -r extracted_file; do
|
|
|
+ ex=$((ex + 1))
|
|
|
+ echo -en "wait... $ex files extracted\r"
|
|
|
+ done
|
|
|
+ else
|
|
|
+ tar xzf "$backup_file" -C /backup/${tmp_dir}
|
|
|
+ fi
|
|
|
+
|
|
|
+ if [ $? -eq 0 ]; then
|
|
|
+ tput setaf 2
|
|
|
+ echo "Backup extracted without errors..."
|
|
|
+ tput sgr0
|
|
|
+ else
|
|
|
+ tput setaf 1
|
|
|
+ echo "Error on backup extraction, check your file and try extracting it manually"
|
|
|
+ tput sgr0
|
|
|
+ delete_tmp
|
|
|
+ exit 1
|
|
|
+ fi
|
|
|
+
|
|
|
+elif file "$backup_file" | grep -q -c "Zstandard compressed data"; then
|
|
|
+ tput setaf 2
|
|
|
+ echo "OK - Zstandard Compressed File"
|
|
|
+ tput sgr0
|
|
|
+
|
|
|
+ if [ ! -d /backup/${tmp_dir} ]; then
|
|
|
+ echo "Creating temporary directory..."
|
|
|
+ mkdir /backup/${tmp_dir}
|
|
|
+ fi
|
|
|
+
|
|
|
+ echo "Extracting backup..."
|
|
|
+ if [ "$debug" != 0 ]; then
|
|
|
+ tar --use-compress-program=pzstd -xvf "$backup_file" -C /backup/${tmp_dir} 2>&1 | while read -r extracted_file; do
|
|
|
+ ex=$((ex + 1))
|
|
|
+ echo -en "wait... $ex files extracted\r"
|
|
|
+ done
|
|
|
else
|
|
|
- tar xzf $backup_file -C /backup/${tmp_dir}
|
|
|
+ tar --use-compress-program=pzstd -xf "$backup_file" -C /backup/${tmp_dir}
|
|
|
fi
|
|
|
+
|
|
|
if [ $? -eq 0 ]; then
|
|
|
tput setaf 2
|
|
|
- echo "Backup extracted whitout errors..."
|
|
|
+ echo "Backup extracted without errors..."
|
|
|
tput sgr0
|
|
|
else
|
|
|
tput setaf 1
|
|
|
- echo "Error on backup extraction, check your file, try extract it manually"
|
|
|
+ echo "Error on backup extraction, check your file and try extracting it manually"
|
|
|
tput sgr0
|
|
|
delete_tmp
|
|
|
exit 1
|
|
|
fi
|
|
|
+
|
|
|
else
|
|
|
tput setaf 1
|
|
|
- echo "Error 3 not-gzip - no standard gziped backup provided of file not installed ( Try yum install file, or apt-get install file )"
|
|
|
+ echo "Error: Unsupported file format or 'file' command not installed (Try 'yum install file' or 'apt-get install file')"
|
|
|
tput sgr0
|
|
|
delete_tmp
|
|
|
exit 3
|
|
|
fi
|
|
|
+
|
|
|
cd /backup/${tmp_dir}/
|
|
|
main_dir=$(pwd)
|
|
|
echo "Access tmp directory $main_dir"
|