Need to migrate Zimbra to Carbonio without losing users, calendars, contacts or email? This guide covers the whole move from Zimbra Open Source Edition to Carbonio Community Edition, with verification commands, the fixes applied and the final scripts.
The scenario is an environment with 330 accounts and more than 600 GB of mail, where both servers share the same hypervisor, keep the hostname mail.guidocutipa.blog.bo, and the domain had already been created in Carbonio CE.
Steps to migrate Zimbra to Carbonio CE
- Preparation: timeouts, allow list and memory.
- Phase 1: export and import LDAP, calendars and contacts.
- Phase 2: move DNS and network to Carbonio CE.
- Phase 3: copy mailboxes with parallel Imapsync.
Before you start: Zimbra and Carbonio CE
| Server | Recommended resources | Role in the migration |
|---|---|---|
| Zimbra OSE (source) | 12 cores, 16 GB RAM | LDAP, calendar and contact export; IMAP reads |
| Carbonio CE (target) | 12 cores, 32 GB RAM | LDAP import, Docker Imapsync and indexing |
1. Raise the socket timeout on both servers (as user zimbra on the source and zextras on the target):
zmlocalconfig -e socket_so_timeout=3000000
zmlocalconfig --reload
2. Allow-list the Carbonio IP in Zimbra (prevents blocks caused by many admin IMAP sessions):
su - zimbra -c "zmprov mcf +zimbraHttpThrottleSafeIPs IP_CARBONIO_SERVER"
Note: if you use Fail2ban on Zimbra, also add IP_CARBONIO_SERVER to ignoreip in /etc/fail2ban/jail.local.
3. Check the available RAM on Zimbra after upgrading to 16 GB:
free -h
Phase 1: Migrate LDAP, calendars and contacts (provisioning)
1.1 Export from Zimbra (source server)
1. As root, export the custom COS and the LDAP data (provisioning.ldif):
mkdir -p /opt/zimbra/backup
/opt/zimbra/common/sbin/slapcat -F /opt/zimbra/data/ldap/config -b "" -s "cn=cos,cn=zimbra" \
-H 'ldap:///???(&(objectClass=zimbraCos)(!(cn=default))(!(cn=defaultExternal)))' \
-l /opt/zimbra/backup/coses.ldif
/opt/zimbra/common/sbin/slapcat -F /opt/zimbra/data/ldap/config -b "" \
-H 'ldap:///???(&(!(entryDN:dnSubTreeMatch:=cn=zimbra)))' > /opt/zimbra/backup/provisioning.ldif
chown zimbra:zimbra /opt/zimbra/backup/*.ldif
Note: the chown command avoids the rsync error (code 23 / Permission denied) during the transfer.
2. Export calendars (.ics) and contacts (.csv) as user zimbra:
su - zimbra
for i in $(zmprov -l gaa guidocutipa.blog.bo); do
zmmailbox -z -m "$i" getRestURL "/Calendar?fmt=ics" > "/opt/zimbra/backup/${i}.ics"
zmmailbox -z -m "$i" getRestURL "/Contacts?fmt=csv" > "/opt/zimbra/backup/${i}.csv"
done
3. Transfer the files to Carbonio CE. First create the target folder on Carbonio (mkdir -p /opt/zextras/backup/), then run this on Zimbra:
cd /opt/zimbra/backup/
rsync -avp coses.ldif provisioning.ldif *.ics *.csv root@IP_CARBONIO_SERVER:/opt/zextras/backup/
1.2 Clean and import LDAP into Carbonio CE (target server)
1. As root, unfold the LDIF lines and remove the old Zimbra chat properties. Both servers are named mail.guidocutipa.blog.bo, so there is no hostname to replace:
perl -p0e 's/\n //g' /opt/zextras/backup/provisioning.ldif > /opt/zextras/backup/provisioning_1.ldif
sed -i '/com_zextras_chat_open/d' /opt/zextras/backup/provisioning_1.ldif
Check: grep -m 3 "zimbraMailHost" /opt/zextras/backup/provisioning_1.ldif must show mail.guidocutipa.blog.bo.
2. Back up the current Carbonio LDAP and import with -c (it skips the existing domain and loads all users, signatures and lists):
/opt/zextras/common/sbin/slapcat -F /opt/zextras/data/ldap/config/ -b "" -l /opt/zextras/backup/carbonio_ldap_antes.ldif
/opt/zextras/common/sbin/slapadd -c -F /opt/zextras/data/ldap/config/ -v -l /opt/zextras/backup/provisioning_1.ldif
Check: su - zextras -c "carbonio prov -l gaa guidocutipa.blog.bo" must list the 330 accounts.
1.3 Set the Spanish locale and HTTPS in Carbonio CE
Warning: do not change the Linux system language; it must stay
en_US.UTF-8. Set the language only inside Carbonio.
1. As user zextras, make Spanish (es) the default for the COS, the migrated accounts and the web admin panel. Replace es with the locale your users need:
su - zextras
carbonio prov mc default zimbraPrefLocale es
carbonio prov ma [email protected] zimbraPrefLocale es
for i in $(carbonio prov -l gaa guidocutipa.blog.bo); do
carbonio prov ma "$i" zimbraPrefLocale es
done
2. Configure HTTPS on port 443 for the domain (required to avoid Connection refused in zmmailbox):
carbonio prov md guidocutipa.blog.bo zimbraPublicServiceHostname mail.guidocutipa.blog.bo \
zimbraPublicServiceProtocol https zimbraPublicServicePort 443
carbonio prov fc domain guidocutipa.blog.bo
Check: carbonio prov gd guidocutipa.blog.bo zimbraPublicServiceHostname zimbraPublicServiceProtocol zimbraPublicServicePort must return mail.guidocutipa.blog.bo, https and 443.
1.4 Restore calendars and contacts (final script)
Save this script as /opt/zextras/backup/restore_cal_contacts.sh. It empties /Contacts only for accounts that have a valid .csv backup, so running it again does not create duplicates. Script messages are in Spanish:
#!/bin/bash
# Carbonio CE - Restauración masiva de Calendarios (.ics) y Contactos (.csv)
DOMAIN="guidocutipa.blog.bo"
BACKUP_DIR="/opt/zextras/backup"
echo "Iniciando restauración de Calendarios y Contactos para: $DOMAIN"
echo "--------------------------------------------------------"
for ACCOUNT in $(carbonio prov -l gaa "$DOMAIN"); do
ICS_FILE="${BACKUP_DIR}/${ACCOUNT}.ics"
CSV_FILE="${BACKUP_DIR}/${ACCOUNT}.csv"
# Restaurar Calendario (.ics)
if [ -s "$ICS_FILE" ]; then
echo "Importando Calendario de $ACCOUNT..."
zmmailbox -z -m "$ACCOUNT" -t 0 postRestURL "/Calendar?fmt=ics" "$ICS_FILE"
else
echo "Omitiendo Calendario de $ACCOUNT (vacío o no existe)"
fi
# Limpiar y Restaurar Contactos (.csv) sin duplicados
if [ -s "$CSV_FILE" ]; then
echo "Limpiando e importando Contactos de $ACCOUNT..."
zmmailbox -z -m "$ACCOUNT" emptyFolder /Contacts
zmmailbox -z -m "$ACCOUNT" -t 0 postRestURL "/Contacts?fmt=csv" "$CSV_FILE"
else
echo "Omitiendo Contactos de $ACCOUNT (vacío o no existe)"
fi
done
echo "--------------------------------------------------------"
echo "Restauración finalizada para $DOMAIN."
Permissions and execution (as root):
chown -R zextras:zextras /opt/zextras/backup/
chmod +x /opt/zextras/backup/restore_cal_contacts.sh
su - zextras -c "/opt/zextras/backup/restore_cal_contacts.sh"
Note: if an account shows ERROR: service.AUTH_EXPIRED, check it with carbonio prov ga [email protected] zimbraAccountStatus (it is usually closed or locked).
Phase 2: Switch services (DNS and network)
- DNS records: point the A (
mail.guidocutipa.blog.bo), MX, SPF/TXT, DKIM and DMARC records to the new Carbonio CE IP. - Perimeter: update the destination IP in the firewall, the antispam gateway (Proxmox) and monitoring tools.
- Check: test sending and receiving internal and external mail directly on Carbonio CE.
Phase 3: Migrate mailboxes with parallel Imapsync
3.1 Install Docker, Screen and the Imapsync image
As root on Carbonio CE:
apt install docker.io screen -y
docker pull gilleslamiral/imapsync
So that large Zimbra messages do not fail, temporarily raise the limit to 100 MB (104857600 bytes) or 150 MB (157286400 bytes). Run as user zextras:
carbonio prov mcf zimbraMtaMaxMessageSize 104857600
carbonio prov mcf zimbraFileUploadMaxSize 104857600
Check: carbonio prov gcf zimbraMtaMaxMessageSize must now return 104857600.
Flush the configuration cache to apply the change:
carbonio prov fc config
Check: the command ends without errors. If IMAP still rejects the message for a specific account, restart only the mailbox service with zmmailboxdctl restart.
After the migration you can restore the original 52 MB limit (54525952) and rerun imapsync only for the accounts listed in resumen_errores.log.
3.2 Final script: migrar_correos.sh
Save it as /opt/zextras/backup/migrar_correos.sh. It runs 10 parallel jobs (a good fit for 12 cores / 16 GB RAM on Zimbra and 12 cores / 32 GB RAM on Carbonio), keeps one log per account and an error summary, and skips folder size calculation for speed.
Security tip: this script stores admin passwords in plain text. Restrict access (for example,
chmod 700), delete it after the migration and change those passwords. Also delete the LDIF backups when you no longer need them, because they contain account data.
#!/bin/bash
# Migración en paralelo Zimbra -> Carbonio CE (guidocutipa.blog.bo)
DOMAIN="guidocutipa.blog.bo"
MAX_JOBS=10
# --- CONFIGURA ESTOS 6 VALORES ANTES DE EJECUTAR ---
IP_ZIMBRA="IP_ZIMBRA_SERVER"
ADMIN_ZIMBRA="[email protected]"
PASS_ZIMBRA='TU_PASSWORD_ZIMBRA'
IP_CARBONIO="IP_CARBONIO_SERVER"
ADMIN_CARBONIO="[email protected]"
PASS_CARBONIO='TU_PASSWORD_CARBONIO'
# ---------------------------------------------------
LOG_DIR="/opt/zextras/backup/imapsync_logs"
ERROR_LOG="${LOG_DIR}/resumen_errores.log"
OK_LOG="${LOG_DIR}/resumen_exitosos.log"
mkdir -p "$LOG_DIR"
: > "$ERROR_LOG"
: > "$OK_LOG"
migrar_cuenta() {
local i="$1"
local ACCOUNT_LOG="${LOG_DIR}/${i}.log"
echo "$(date '+%H:%M:%S') | [INICIO] $i"
docker run --rm gilleslamiral/imapsync imapsync \
--host1 "$IP_ZIMBRA" --ssl1 --user1 "$i" --authuser1 "$ADMIN_ZIMBRA" --password1 "$PASS_ZIMBRA" \
--host2 "$IP_CARBONIO" --ssl2 --user2 "$i" --authuser2 "$ADMIN_CARBONIO" --password2 "$PASS_CARBONIO" \
--nofoldersizes --nofoldersizesatend \
--noreleasecheck > "$ACCOUNT_LOG" 2>&1
local EXIT_CODE=$?
if [ $EXIT_CODE -eq 0 ]; then
echo "$(date '+%H:%M:%S') | [OK] $i"
echo "$(date '+%F %T') | OK | $i" >> "$OK_LOG"
else
echo "$(date '+%H:%M:%S') | [ERROR] $i (código $EXIT_CODE)"
echo "$(date '+%F %T') | ERROR ($EXIT_CODE) | $i | Ver: $ACCOUNT_LOG" >> "$ERROR_LOG"
fi
}
echo "Iniciando migración IMAP ($MAX_JOBS hilos) para $DOMAIN - $(date)"
echo "Logs detallados en: $LOG_DIR"
echo "---------------------------------------------------"
for i in $(su - zextras -c "carbonio prov -l gaa $DOMAIN"); do
# Omitir cuentas internas del sistema
if [[ "$i" == spam.* || "$i" == ham.* || "$i" == virus-quarantine.* || "$i" == galsync* ]]; then
echo "[OMITIDA] Cuenta de sistema: $i"
continue
fi
# Mantener máximo MAX_JOBS cuentas simultáneas
while [ "$(jobs -rp | wc -l)" -ge "$MAX_JOBS" ]; do
sleep 2
done
migrar_cuenta "$i" &
sleep 1
done
wait
echo "---------------------------------------------------"
echo "Migración finalizada - $(date)"
echo "Cuentas exitosas : $(wc -l < "$OK_LOG")"
echo "Cuentas con error: $(wc -l < "$ERROR_LOG")"
echo "Resumen de errores: $ERROR_LOG"
3.3 Run, monitor and control
1. Make it executable and run it in the background with screen:
chmod +x /opt/zextras/backup/migrar_correos.sh
screen -S migracion
/opt/zextras/backup/migrar_correos.sh
Note: to leave without stopping the migration, press Ctrl + A, then D. To return, run screen -r migracion.
2. Monitor progress and errors from another SSH terminal:
docker ps --format "table {{.ID}}\t{{.RunningFor}}\t{{.Status}}"
wc -l /opt/zextras/backup/imapsync_logs/resumen_*.log
cat /opt/zextras/backup/imapsync_logs/resumen_errores.log
3. Stop safely (no lost or duplicated mail): if the hypervisor IO delay goes above 35–40%, press Ctrl + C inside screen and stop the running containers:
docker stop $(docker ps -q --filter ancestor=gilleslamiral/imapsync)
Resume: lower MAX_JOBS (for example, to 6 or 8) and run the script again. Imapsync skips the messages already copied and continues where it left off.
FAQ: how to migrate Zimbra to Carbonio CE
Can I migrate Zimbra to Carbonio keeping the same hostname?
Yes. In this procedure both servers use mail.guidocutipa.blog.bo, so the hostname does not need to be replaced in the LDIF file.
What data does this guide migrate from Zimbra to Carbonio CE?
Custom COS and LDAP data (users, signatures and lists), calendars in .ics format, contacts in .csv format, and email through Imapsync.
What happens if I stop Imapsync halfway?
Run the script again: Imapsync skips the messages already copied and continues where it left off.
Next steps in Carbonio CE
- How to configure Z-push for Carbonio CE (in Spanish)
- Free Let’s Encrypt SSL certificates on Carbonio CE (in Spanish)
Official resources: Carbonio Community Edition, Zextras documentation, Imapsync and its Docker Hub image.
Discover more from Blog personal de Guido Cutipa
Subscribe to get the latest posts sent to your email.