Migrating mail accounts to another MyVestaCP server

Post Reply
darden
Posts: 11
Joined: Wed May 05, 2021 3:38 pm

Hello there,

Let's say we would like to migrate from a MyVestaCP server to another, all the mail accounts under a mail domain.
At the first old server, we have several accounts in use in a mail domain.
At the second new server, we create the mail domain, but not the accounts.

¿Is there any tool provided for this?
¿Its good idea to use doveadm or rsync instead of imapsync (we have not accounts at the second server)?

Thanks!

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

The 'rsync' is just fine.
Just before rsync, create those email accounts on the second server.
darden
Posts: 11
Joined: Wed May 05, 2021 3:38 pm

myVesta wrote: Mon Dec 22, 2025 4:38 pm The 'rsync' is just fine.
Just before rsync, create those email accounts on the second server.
Yes, thanks, been testing, and rsync after creating accounts works just fine.
darden
Posts: 11
Joined: Wed May 05, 2021 3:38 pm

Hi again, just for anyone looking for this.

First, create mail domains & accounts, at the local new Server, with p.e. random passwords. In case large amount of accounts, use:

Code: Select all

/usr/local/vesta/bin/v-list-mail-accounts
Get the accounts names and use Bash p.e.:

Code: Select all

#!/bin/bash
ACCOUNTS=(
account1
account2
account3
)
gen_pass() {
  tr -dc 'A-Za-z0-9' </dev/urandom | head -c 8
}
for ACCOUNT in "${ACCOUNTS[@]}"; do
  PASSWORD=$(gen_pass)

  /usr/local/vesta/bin/v-add-mail-account [domain] "$ACCOUNT" "$PASSWORD"

  echo "Account created: $ACCOUNT@[domain]"
done
Then Rsync:

Code: Select all

sudo -u [local-vesta-user] rsync -avzt --progress -e "ssh -p [port]" [remote-vesta-user]@[remote-server]:/home/[remote-vesta-user]/mail/[domain]/ /home/[local-vesta-user]/mail/[domain]
sudo chown [local-vesta-user]:mail -R /home/[local-vesta-user]/mail/[domain]
Then just copy settings from

Code: Select all

/home/[remote-vesta-user]/conf/mail/[domain]
and adjust (like inside the passwd file).
Take a look at permissions, from remote folders and set the same at the local ones.

This way is possible to migrate accounts with same credentials.
(Not sure if necessary to clean dovecot cache files).
Post Reply