Skip to content

Commit 20de29a

Browse files
committed
Modify backup-system check function, thanks to @FalzoMAD
1 parent 7ffcb60 commit 20de29a

File tree

1 file changed

+10
-24
lines changed

1 file changed

+10
-24
lines changed

bin/v-restore-user

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -244,23 +244,23 @@ fi
244244
# Set default backup source system
245245
backup_system="hestia"
246246

247+
# Check if it is a vesta backup
248+
if tar -tf $BACKUP/$backup ./vesta >/dev/null 2>&1; then
249+
backup_system="vesta"
250+
fi
251+
247252
# Restoring user account
248253
if [ "$create_user" = 'yes' ]; then
249254
echo "-- USER --" |tee $tmpdir/restore.log
250255
echo -e "$(date "+%F %T") $user" |tee -a $tmpdir/restore.log
251256

252257
# Unpacking user container
253-
tar xf $BACKUP/$backup -C $tmpdir ./hestia 2>/dev/null
258+
tar xf $BACKUP/$backup -C $tmpdir ./$backup_system 2>/dev/null
254259
if [ "$?" -ne 0 ]; then
255-
tar xf $BACKUP/$backup -C $tmpdir ./vesta 2>/dev/null
256-
if [ "$?" -ne 0 ]; then
257-
rm -rf $tmpdir
258-
echo "Can't unpack user container" |$SENDMAIL -s "$subj" $email $notify
259-
sed -i "/ $user /d" $HESTIA/data/queue/backup.pipe
260-
check_result "$E_PARSING" "Can't unpack user container"
261-
else
262-
backup_system="vesta"
263-
fi
260+
rm -rf $tmpdir
261+
echo "Can't unpack user container" |$SENDMAIL -s "$subj" $email $notify
262+
sed -i "/ $user /d" $HESTIA/data/queue/backup.pipe
263+
check_result "$E_PARSING" "Can't unpack user container"
264264
fi
265265

266266
# Restoring user.conf
@@ -271,20 +271,6 @@ if [ "$create_user" = 'yes' ]; then
271271

272272
# Rebuilding user
273273
rebuild_user_conf
274-
else
275-
# Unpacking user container to check if hestia or vesta backup.
276-
tar xf $BACKUP/$backup -C $tmpdir ./hestia 2>/dev/null
277-
if [ "$?" -ne 0 ]; then
278-
tar xf $BACKUP/$backup -C $tmpdir ./vesta 2>/dev/null
279-
if [ "$?" -ne 0 ]; then
280-
rm -rf $tmpdir
281-
echo "Can't unpack user container" |$SENDMAIL -s "$subj" $email $notify
282-
check_result "$E_PARSING" "Can't unpack user container"
283-
else
284-
backup_system="vesta"
285-
fi
286-
fi
287-
fi
288274

289275
# Unpacking pam container
290276
tar xf $BACKUP/$backup -C $tmpdir ./pam

0 commit comments

Comments
 (0)