How to Migrate and Bulk Delete User Aliases in Zimbra

Looking to migrate to ZCS? Ask here. Got a great tip or script that helped you migrate? Post it here.
Post Reply
hashir
Posts: 2
Joined: Thu May 29, 2025 6:07 pm

How to Migrate and Bulk Delete User Aliases in Zimbra

Post by hashir »

Old server:

Create an empty file to store all aliases and set file ownership to zimbra

Code: Select all

# touch /tmp/all_accts_aliases.txt && chown zimbra:zimbra /tmp/all_accts_aliases.txt

# su - zimbra
Export all aliases into a file.

Code: Select all

$ for accts in $(zmprov -l gaa | grep -Ev "^(spam|ham|virus|galsync)"); do zmprov ga $accts zimbraMailAlias | awk -v acct=$accts ' /zimbraMailAlias:/  {print "aaa", acct, $2}' >> /tmp/all_accts_aliases.txt; done
Example:
aaa hashir.saud@domain.com 1234@domain.com
aaa ali@domain.com 4545@domain.com

Copy the aliases file to the new server

Code: Select all

# scp /tmp/all_accts_aliases.txt root@<new_server_ip>:/tmp/

New Server:

Set file ownership to zimbra

Code: Select all

# chown zimbra:zimbra /tmp/all_accts_aliases.txt

# su - zimbra 
Import all aliases into the new server

Code: Select all

$ zmprov < /tmp/all_accts_aliases.txt


Delete bulk user aliases:

Code: Select all

# touch /tmp/del_all_accts_aliases.txt && chown zimbra:zimbra /tmp/del_all_accts_aliases.txt

# su - zimbra

$ for accts in $(zmprov -l gaa | grep -Ev "^(admin|spam|ham|galsync)"); do zmprov ga $accts zimbraMailAlias | awk -v acct=$accts ' /zimbraMailAlias:/  {print "raa", acct, $2}' >> /tmp/del_all_accts_aliases.txt; done
Example:
raa hashir.saud@domain.com 1234@domain.com
raa ali@domain.com 4545@domain.com

Code: Select all

$ zmprov < /tmp/del_all_accts_aliases.txt
Post Reply