Skip to content

Commit 699ff14

Browse files
committed
Restore user backup was creating incorrect configs when source file had missing cfg keys
Relates to issue hestiacp#616 Display a warning message when backup database is missing the password (Relates to issue hestiacp#415)
1 parent ef655e2 commit 699ff14

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

bin/v-restore-user

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,9 @@ if [ "$web" != 'no' ] && [ ! -z "$WEB_SYSTEM" ]; then
291291
for domain in $domains; do
292292
echo -e "$(date "+%F %T") $domain" |tee -a $tmpdir/restore.log
293293

294+
# Cleanup previous domain keys
295+
unset -v DOMAIN IP IP6 ALIAS TPL SSL SSL_HOME LETSENCRYPT FTP_USER FTP_MD5 BACKEND PROXY PROXY_EXT STATS STATS_USER STATS_CRYPT U_DISK
296+
294297
# Checking domain existance
295298
check_config=$(grep "DOMAIN='$domain'" $USER_DATA/web.conf)
296299
if [ -z "$check_config" ]; then
@@ -455,6 +458,9 @@ if [ "$dns" != 'no' ] && [ ! -z "$DNS_SYSTEM" ]; then
455458
for domain in $domains; do
456459
echo -e "$(date "+%F %T") $domain" |tee -a $tmpdir/restore.log
457460

461+
# Cleanup previous config keys
462+
unset -v DOMAIN IP TPL TTL EXP SOA RECORDS
463+
458464
# Checking domain existance
459465
check_config=$(grep "DOMAIN='$domain'" $USER_DATA/dns.conf)
460466
if [ -z "$check_config" ]; then
@@ -649,6 +655,9 @@ if [ "$db" != 'no' ] && [ ! -z "$DB_SYSTEM" ]; then
649655
for database in $databases; do
650656
echo -e "$(date "+%F %T") $database" |tee -a $tmpdir/restore.log
651657

658+
# Cleanup previous config keys
659+
unset -v DB DBUSER MD5 HOST TYPE CHARSET U_DISK
660+
652661
# Checking database existance
653662
check_config=$(grep "DB='$database'" $USER_DATA/db.conf)
654663

@@ -665,6 +674,12 @@ if [ "$db" != 'no' ] && [ ! -z "$DB_SYSTEM" ]; then
665674
# Restore database config
666675
if [ -z "$check_config" ]; then
667676
parse_object_kv_list $(cat $tmpdir/db/$database/$backup_system/db.conf)
677+
678+
if [ -z "$MD5" ]; then
679+
echo "Warning!: Database ${DB} backup does not contain a password for user ${DBUSER}."
680+
echo "- Please use the web interface to set a password after the restore process finishes."
681+
fi
682+
668683
DB=$(echo "$DB" |sed -e "s/${old_user}_//")
669684
DB="${user}_${DB}"
670685
DBUSER=$(echo "$DBUSER" |sed -e "s/${old_user}_//")

0 commit comments

Comments
 (0)