Page 1 of 1
Migrating mail accounts to another MyVestaCP server
Posted: Mon Dec 22, 2025 4:25 pm
by darden
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!
Re: Migrating mail accounts to another MyVestaCP server
Posted: Mon Dec 22, 2025 4:38 pm
by myVesta
The 'rsync' is just fine.
Just before rsync, create those email accounts on the second server.
Re: Migrating mail accounts to another MyVestaCP server
Posted: Tue Dec 23, 2025 8:39 am
by darden
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.
Re: Migrating mail accounts to another MyVestaCP server
Posted: Mon Dec 29, 2025 3:23 pm
by darden
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).