From 37a2525ab0e752ffb9a047934d4ae9ab39543837 Mon Sep 17 00:00:00 2001 From: MadeITBelgium Date: Sat, 23 Sep 2017 15:09:27 +0000 Subject: [PATCH] Fix backup --- bin/v-backup-user | 98 ++++++++++++++++++++++++++++++++++------------ bin/v-restore-user | 13 +++++- 2 files changed, 85 insertions(+), 26 deletions(-) diff --git a/bin/v-backup-user b/bin/v-backup-user index 6749f1c1..59bf483f 100755 --- a/bin/v-backup-user +++ b/bin/v-backup-user @@ -146,35 +146,83 @@ if [ ! -z "$WEB_SYSTEM" ] && [ "$WEB" != '*' ]; then cd $tmpdir/web/$domain/ conf="$USER_DATA/web.conf" grep "DOMAIN='$domain'" $conf > vesta/web.conf - - # Backup vhost config - tpl_file="$WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$TPL.tpl" - conf="$HOMEDIR/$user/conf/web/$WEB_SYSTEM.conf" - get_web_config_lines $tpl_file $conf - sed -n "$top_line,$bottom_line p" $conf > conf/$WEB_SYSTEM.conf - - # Backup ssl vhost - if [ "$SSL" = 'yes' ]; then - tpl_file="$WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$TPL.stpl" - conf="$HOMEDIR/$user/conf/web/s$WEB_SYSTEM.conf" + + if [ ! -z "$IP" ]; then + old="$IP" + # Backup vhost config + tpl_file="$WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$TPL.tpl" + conf="$HOMEDIR/$user/conf/web/$WEB_SYSTEM.conf" get_web_config_lines $tpl_file $conf - sed -n "$top_line,$bottom_line p" $conf > conf/s$WEB_SYSTEM.conf + sed -n "$top_line,$bottom_line p" $conf > conf/$WEB_SYSTEM.conf + + # Backup ssl vhost + if [ "$SSL" = 'yes' ]; then + tpl_file="$WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$TPL.stpl" + conf="$HOMEDIR/$user/conf/web/s$WEB_SYSTEM.conf" + get_web_config_lines $tpl_file $conf + sed -n "$top_line,$bottom_line p" $conf > conf/s$WEB_SYSTEM.conf + fi + + # Backup proxy config + if [ ! -z "$PROXY_SYSTEM" ] && [ ! -z "$PROXY" ]; then + tpl_file="$WEBTPL/$PROXY_SYSTEM/$PROXY.tpl" + conf="$HOMEDIR/$user/conf/web/$PROXY_SYSTEM.conf" + get_web_config_lines $tpl_file $conf + sed -n "$top_line,$bottom_line p" $conf > conf/$PROXY_SYSTEM.conf + fi + + # Backup ssl proxy config + if [ ! -z "$PROXY_SYSTEM" ] && [ "$SSL" = 'yes' ]; then + tpl_file="$WEBTPL/$PROXY_SYSTEM/$PROXY.stpl" + conf="$HOMEDIR/$user/conf/web/s$PROXY_SYSTEM.conf" + get_web_config_lines $tpl_file $conf + sed -n "$top_line,$bottom_line p" $conf > conf/s$PROXY_SYSTEM.conf + fi fi - - # Backup proxy config - if [ ! -z "$PROXY_SYSTEM" ] && [ ! -z "$PROXY" ]; then - tpl_file="$WEBTPL/$PROXY_SYSTEM/$PROXY.tpl" - conf="$HOMEDIR/$user/conf/web/$PROXY_SYSTEM.conf" + + if [ ! -z "$IP6" ]; then + if [ -z "$IP" ]; then + echo "" > conf/$WEB_SYSTEM.conf + if [ "$SSL" = 'yes' ]; then + echo "" > conf/s$WEB_SYSTEM.conf + fi + if [ ! -z "$PROXY_SYSTEM" ] && [ ! -z "$PROXY" ]; then + echo "" > conf/$PROXY_SYSTEM.conf + fi + if [ ! -z "$PROXY_SYSTEM" ] && [ "$SSL" = 'yes' ]; then + echo > conf/s$PROXY_SYSTEM.conf + fi + fi + old=$IP6 + # Backup vhost config + tpl_file="$WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$TPL.tpl" + conf="$HOMEDIR/$user/conf/web/$WEB_SYSTEM.conf" get_web_config_lines $tpl_file $conf - sed -n "$top_line,$bottom_line p" $conf > conf/$PROXY_SYSTEM.conf - fi + sed -n "$top_line,$bottom_line p" $conf >> conf/$WEB_SYSTEM.conf - # Backup ssl proxy config - if [ ! -z "$PROXY_SYSTEM" ] && [ "$SSL" = 'yes' ]; then - tpl_file="$WEBTPL/$PROXY_SYSTEM/$PROXY.stpl" - conf="$HOMEDIR/$user/conf/web/s$PROXY_SYSTEM.conf" - get_web_config_lines $tpl_file $conf - sed -n "$top_line,$bottom_line p" $conf > conf/s$PROXY_SYSTEM.conf + # Backup ssl vhost + if [ "$SSL" = 'yes' ]; then + tpl_file="$WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$TPL.stpl" + conf="$HOMEDIR/$user/conf/web/s$WEB_SYSTEM.conf" + get_web_config_lines $tpl_file $conf + sed -n "$top_line,$bottom_line p" $conf >> conf/s$WEB_SYSTEM.conf + fi + + # Backup proxy config + if [ ! -z "$PROXY_SYSTEM" ] && [ ! -z "$PROXY" ]; then + tpl_file="$WEBTPL/$PROXY_SYSTEM/$PROXY.tpl" + conf="$HOMEDIR/$user/conf/web/$PROXY_SYSTEM.conf" + get_web_config_lines $tpl_file $conf + sed -n "$top_line,$bottom_line p" $conf >> conf/$PROXY_SYSTEM.conf + fi + + # Backup ssl proxy config + if [ ! -z "$PROXY_SYSTEM" ] && [ "$SSL" = 'yes' ]; then + tpl_file="$WEBTPL/$PROXY_SYSTEM/$PROXY.stpl" + conf="$HOMEDIR/$user/conf/web/s$PROXY_SYSTEM.conf" + get_web_config_lines $tpl_file $conf + sed -n "$top_line,$bottom_line p" $conf >> conf/s$PROXY_SYSTEM.conf + fi fi # Backup custom config diff --git a/bin/v-restore-user b/bin/v-restore-user index 477f01ac..887bc443 100755 --- a/bin/v-restore-user +++ b/bin/v-restore-user @@ -492,13 +492,16 @@ if [ "$dns" != 'no' ] && [ ! -z "$DNS_SYSTEM" ]; then old_ip=$IP IP=$ip fi + # Checking ipv6 address check_ipv6=$(is_ipv6_valid $IP6 $user) if [ ! -z "$check_ipv6" ]; then local_ip6='' get_user_ipv6 $user old_ipv6=$IP6 - IP=$ipv6 + IP6=$ipv6 + else + old_ipv6='' fi # Checking dns template @@ -516,6 +519,14 @@ if [ "$dns" != 'no' ] && [ ! -z "$DNS_SYSTEM" ]; then # Restoring dns records cp -f $tmpdir/dns/$domain/vesta/$domain.conf $USER_DATA/dns/ + if [ -z "$old_ipv6" ] && [ ! -z "$IP6" ]; then + time_n_date=$(date +'%T %F') + time=$(echo "$time_n_date" |cut -f 1 -d \ ) + date=$(echo "$time_n_date" |cut -f 2 -d \ ) + ip="" + ipv6="$IP6" + add_dns_config_records + fi # Rebuilding dns domain rebuild_dns_domain_conf