Skip to content

Commit f9e44f0

Browse files
committed
Create compatibility to restore vesta backups.
1 parent f5b9262 commit f9e44f0

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

bin/v-restore-user

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -255,11 +255,18 @@ if [ "$create_user" = 'yes' ]; then
255255
check_result "$E_PARSING" "can't unpack user contaner"
256256
fi
257257

258+
# Check if it is a vesta or hestia backup
259+
if [ -d "$tmpdir/vesta" ]; then
260+
backup_system="vesta"
261+
else
262+
backup_system="hestia"
263+
fi
264+
258265
# Restoring user.conf
259266
mkdir $USER_DATA
260-
cp $tmpdir/hestia/user.conf $USER_DATA/
261-
cp -r $tmpdir/hestia/ssl $USER_DATA/ >/dev/null 2>&1
262-
cp $tmpdir/hestia/backup-excludes.conf $USER_DATA/ >/dev/null 2>&1
267+
cp $tmpdir/$backup_system/user.conf $USER_DATA/
268+
cp -r $tmpdir/$backup_system/ssl $USER_DATA/ >/dev/null 2>&1
269+
cp $tmpdir/$backup_system/backup-excludes.conf $USER_DATA/ >/dev/null 2>&1
263270

264271
# Rebuilding user
265272
rebuild_user_conf
@@ -322,7 +329,7 @@ if [ "$web" != 'no' ] && [ ! -z "$WEB_SYSTEM" ]; then
322329

323330
# Restoring web.conf
324331
if [ -z "$check_config" ]; then
325-
eval $(cat $tmpdir/web/$domain/hestia/web.conf)
332+
eval $(cat $tmpdir/web/$domain/$backup_system/web.conf)
326333

327334
# Deleting conflicting aliases
328335
for dom_alias in ${ALIAS//,/ }; do
@@ -485,7 +492,7 @@ if [ "$dns" != 'no' ] && [ ! -z "$DNS_SYSTEM" ]; then
485492

486493
# Restoring dns.conf
487494
if [ -z "$check_config" ]; then
488-
eval $(cat $tmpdir/dns/$domain/hestia/dns.conf)
495+
eval $(cat $tmpdir/dns/$domain/$backup_system/dns.conf)
489496

490497
# Checking ip address
491498
check_ip=$(is_ip_valid $IP $user)
@@ -510,7 +517,7 @@ if [ "$dns" != 'no' ] && [ ! -z "$DNS_SYSTEM" ]; then
510517
fi
511518

512519
# Restoring dns records
513-
cp -f $tmpdir/dns/$domain/hestia/$domain.conf $USER_DATA/dns/
520+
cp -f $tmpdir/dns/$domain/$backup_system/$domain.conf $USER_DATA/dns/
514521

515522
# Rebuilding dns domain
516523
rebuild_dns_domain_conf
@@ -572,17 +579,17 @@ if [ "$mail" != 'no' ] && [ ! -z "$MAIL_SYSTEM" ]; then
572579

573580
# Restoring mail.conf
574581
if [ -z "$check_config" ]; then
575-
cat $tmpdir/mail/$domain/hestia/mail.conf >> $USER_DATA/mail.conf
582+
cat $tmpdir/mail/$domain/$backup_system/mail.conf >> $USER_DATA/mail.conf
576583
fi
577584

578585
# Restoring DKIM
579-
if [ -e "$tmpdir/mail/$domain/hestia/$domain.pem" ]; then
580-
cp -f $tmpdir/mail/$domain/hestia/$domain.pem $USER_DATA/mail/
581-
cp -f $tmpdir/mail/$domain/hestia/$domain.pub $USER_DATA/mail/
586+
if [ -e "$tmpdir/mail/$domain/$backup_system/$domain.pem" ]; then
587+
cp -f $tmpdir/mail/$domain/$backup_system/$domain.pem $USER_DATA/mail/
588+
cp -f $tmpdir/mail/$domain/$backup_system/$domain.pub $USER_DATA/mail/
582589
fi
583590

584591
# Restoring email accounts
585-
cp -f $tmpdir/mail/$domain/hestia/$domain.conf $USER_DATA/mail/
592+
cp -f $tmpdir/mail/$domain/$backup_system/$domain.conf $USER_DATA/mail/
586593

587594
# Rebuilding mail config
588595
rebuild_mail_domain_conf
@@ -650,7 +657,7 @@ if [ "$db" != 'no' ] && [ ! -z "$DB_SYSTEM" ]; then
650657

651658
# Restore database config
652659
if [ -z "$check_config" ]; then
653-
eval $(cat $tmpdir/db/$database/hestia/db.conf)
660+
eval $(cat $tmpdir/db/$database/$backup_system/db.conf)
654661
DB=$(echo "$DB" |sed -e "s/${old_user}_//")
655662
DB="${user}_${DB}"
656663
DBUSER=$(echo "$DBUSER" |sed -e "s/${old_user}_//")

0 commit comments

Comments
 (0)