How to move accounts from one (my)Vesta server to another myVesta server

User avatar
myVesta
Site Admin
Posts: 946
Joined: Fri Jun 19, 2020 9:59 am
Has thanked: 9 times
Been thanked: 6 times

This tutorial is general manual for both situations:
  • moving sites from old Vesta server to new myVesta server
  • moving sites from one myVesta server to another myVesta server

Here we go:
  • On your old (my)Vesta server, in SSH, as root, run:

    Code: Select all

    export ALLOW_BACKUP_ANYTIME='yes'
    nice -n 19 ionice -c 3 v-backup-users
    or if you want to migrate only specific account, then:

    Code: Select all

    export ALLOW_BACKUP_ANYTIME='yes'
    nice -n 19 ionice -c 3 v-backup-user UsernameOfAccount
  • Copy files from /backup to some remote server, or to your computer
  • Install myVesta on new server if it's not already installed
  • Create /backup folder on new myVesta server (if it's not already created)
  • Now copy your generated backup files from remote server (or from your computer) to /backup folder on new myVesta server
  • On new myVesta server, in SSH, as root, run:

    Code: Select all

    nice -n 19 ionice -c 3 v-restore-user UsernameOfAccount UsernameOfAccount.2020-06-20_01-10-02.tar
    (of course use proper username and filename that exists)

Normally, after restoring backups, your imported domains will have DNS that contains NS1, NS2 and IP of the original (old) server.
If it differs from the server you importing backup, you can do in SSH, as root:

Code: Select all

v-normalize-restored-user YOUR_USERNAME
and that command will automatically put NS1, NS2 and IP of your current server.


Advice: don't kill old server before you bring everything on new.
Or, if it's cloud, please make snapshot of old server before you kill it.

We saw the situations where people got corruptred backups because there was no free space on old server to make full backup.
They didn't noticed that (they didn't check /usr/local/vesta/log/backup.log) and killed server with thinking that everything is in backup files.
They had supprise when they tried to restore them on new server :(

Tags:
colifato
Posts: 1
Joined: Tue Jun 22, 2021 1:53 am

Thank you for accepting the forum registration.
I have a query .. in the case of migrating from HestiaCP to myVesta, the steps to follow would be the same as from Vesta to myVesta?
From already thank you very much.
User avatar
myVesta
Site Admin
Posts: 946
Joined: Fri Jun 19, 2020 9:59 am
Has thanked: 9 times
Been thanked: 6 times

colifato wrote: Tue Jun 22, 2021 2:58 pm Thank you for accepting the forum registration.
I have a query .. in the case of migrating from HestiaCP to myVesta, the steps to follow would be the same as from Vesta to myVesta?
From already thank you very much.
I'm afraid Hestia modified backup format.
You can try to import, anyway, maybe old stuff is on the same place in backups...give it a try :|
User avatar
Amadex
Posts: 13
Joined: Tue Jun 23, 2020 3:25 pm
Your location: Europe
First name and last name: Amar Dugonja
Been thanked: 4 times

v-normalize-restored-user was not working for me, it replaced new ip with guess what... new ip again. :roll:

So I have added manually my old IP to the script and it worked:


#!/bin/bash

# info:
# Normalize NS1, NS2 and IP of account that is backuped on other server and restored on this server.
# After restoring, user will have DNS that contains NS1, NS2 and IP from original server
# This script will put NS1, NS2 and IP of current server

# options: user

#----------------------------------------------------------#
# Variable&Function #
#----------------------------------------------------------#

whoami=$(whoami)
if [ "$whoami" != "root" ] && [ "$whoami" != "admin" ] ; then
echo "You must be root or admin to execute this script";
exit 1;
fi


# Argument definition
user=$1

# Includes
source $VESTA/func/main.sh


#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#

check_args '1' "$#" 'USER'
is_format_valid 'user'
is_object_valid 'user' 'USER' "$user"

#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#

source $VESTA/data/packages/default.pkg

arrNS=(${NS//,/ })
NEWNS1=${arrNS[0]}
NEWNS2=${arrNS[1]}

for domain in $(/usr/local/vesta/bin/v-list-web-domains $user plain |cut -f 1); do
if [ -f "/usr/local/vesta/data/users/$user/dns/$domain.conf" ]; then
NEWIPV4=$(/usr/local/vesta/bin/v-list-dns-domain "$user" "$domain" | grep 'IP:' | awk '{print $2}')
res=$(grep "'www'" /usr/local/vesta/data/users/$user/dns/$domain.conf)
eval $res
OLDIPV4=$VALUE OLDIPV4=123.45.67.89
fi
if [ ! -z "$NEWIPV4" ] && [ ! -z "$OLDIPV4" ]; then
break;
fi
done


source /usr/local/vesta/data/users/$user/user.conf
arrNS=(${NS//,/ })
OLDNS1=${arrNS[0]}
OLDNS2=${arrNS[1]}

echo "user = $user"
echo "old ns1 = $OLDNS1"
echo "old ns2 = $OLDNS2"
echo "new ns1 = $NEWNS1"
echo "new ns2 = $NEWNS2"
echo "old ip = $OLDIPV4"
echo "new ip = $NEWIPV4"

find /home/$user/conf/dns/ -type f -exec sed -i "s#$OLDIPV4#$NEWIPV4#g" {} \;
find /home/$user/conf/dns/ -type f -exec sed -i "s#$OLDNS1#$NEWNS1#g" {} \;
find /home/$user/conf/dns/ -type f -exec sed -i "s#$OLDNS2#$NEWNS2#g" {} \;
find /usr/local/vesta/data/users/$user/dns/ -type f -exec sed -i "s#$OLDIPV4#$NEWIPV4#g" {} \;
find /usr/local/vesta/data/users/$user/dns/ -type f -exec sed -i "s#$OLDNS1#$NEWNS1#g" {} \;
find /usr/local/vesta/data/users/$user/dns/ -type f -exec sed -i "s#$OLDNS2#$NEWNS2#g" {} \;
sed -i "s#$OLDIPV4#$NEWIPV4#g" /usr/local/vesta/data/users/$user/dns.conf
sed -i "s#$OLDNS1#$NEWNS1#g" /usr/local/vesta/data/users/$user/dns.conf
sed -i "s#$OLDNS1#$NEWNS1#g" /usr/local/vesta/data/users/$user/user.conf
sed -i "s#$OLDNS2#$NEWNS2#g" /usr/local/vesta/data/users/$user/user.conf
systemctl reload bind9

echo "Done!"

# Logging
log_event "$OK" "$ARGUMENTS"

exit
User avatar
webxtek
Posts: 51
Joined: Wed Nov 18, 2020 7:43 pm

Hey mate, any solution for this?
oldns.png
oldns.png (30.96 KiB)
Afer moving the backup from server A to B (both running myvesta), and after running the script you talk about in this thread to replace all ip and dns values, i still keep seeing my old dns there, everything is working fine but its showing the old dns there
halinh
Posts: 1
Joined: Tue Oct 18, 2022 10:31 am

I would be very grateful if there is a video tutorial.

Thank you !
kjernekrafttrikk
Posts: 9
Joined: Sat Apr 09, 2022 1:17 pm

I advice to not so experienced admins (like me) to be careful with their backup files. Transfer them via rsync better, because FTP-transferred file was interpreted as corrupted from the very start.
Jpsciolli
Posts: 13
Joined: Sun Feb 21, 2021 6:54 pm

Hello I am migrating an old vesta to a new server and when I use the v-normalize-restored-user I receive this:
-bash: v-normalize-restored-user: command not found

Is there a path to the command?
thanks

JPS
User avatar
bonya
Posts: 9
Joined: Fri Mar 19, 2021 2:01 am

Jpsciolli wrote: Thu Feb 01, 2024 9:10 pm Hello I am migrating an old vesta to a new server and when I use the v-normalize-restored-user I receive this:
-bash: v-normalize-restored-user: command not found

Is there a path to the command?
thanks

JPS
Hi,
you should run this command under root
or (under sudo user)

Code: Select all

/usr/local/vesta/bin/v-normalize-restored-user
Hockeywain
Posts: 2
Joined: Mon Jun 24, 2024 7:19 am

Hello greetings I have a problem running vestacp on my Linux machine I get this error message


package yum has no installation candidate
Post Reply