Skip to content

Instantly share code, notes, and snippets.

@rwjblue
Created September 26, 2012 21:52
Show Gist options
  • Save rwjblue/3790858 to your computer and use it in GitHub Desktop.
Save rwjblue/3790858 to your computer and use it in GitHub Desktop.
List account and distribution list details in Zimbra
sudo su - zimbra
# list all accounts and print out account name and aliases
for i in `zmprov -l gaa` ; do zmprov ga $i zimbraMailAlias ; done
# list all distribution lists and any members and/or aliases
for i in `zmprov gadl` ; do zmprov gdl $i zimbraMailAlias zimbraMailForwardingAddress ; done
@ginesgb
Copy link

ginesgb commented Dec 22, 2020

Hello, I am trying to migrate the aliases from an old server to a modern server, exporting the aliases has been easy, I have done it this way.

I create the entire mailing list of any zimbra domain

su zimbra
zmprov -l gaa >emails.txt

I get the list of the aliases of the email accounts this way

mkdir -p alias/
chown -R zimbra:zimbra alias/
su zimbra
for i in cat emails.txt; do zmprov ga $i | grep zimbraMailAlias |awk '{print $2}' > alias/$i.txt ;echo $i ;done

Once I have the aliases for each email account, we proceed to delete the email files that do not have any aliases in this way from the list.

find alias/ -type f -empty | xargs -n1 rm -v

Now I upload the files obtained that are emails.txt and the directory of /alias to the destination server, and here is where I have the error, I have made a script to perform the upload but I think I'm doing it wrong, I do not know if it is for permissions or otherwise, the script is this.

#!/bin/bash
for i in cat /opt/zimbra/migracion/emails.txt
do
if [ -f "alias/$i.txt" ]; then
for j in grep '@' /opt/zimbra/migracion/alias/$i.txt
do
zmprov aaa $i $j
echo "$i HAS ALIAS $j --- Restored"
done
fi
done

Can you tell me what mistake I am making?
Greetings and thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment