User Tools

Site Tools
# Written by Thomas York
# Dumps distribution lists and distribution list membership to a file for recreation
# Check to make sure the supplied an argument to the script
if [ "x$1" == "x" ] ; then
        echo "Usage:";
        echo "         $0 <backup file>";
        echo "";
        exit 1;
# Assign some constants
readonly OUTPUTFILE=$1;
# Clear output file
echo -n "" > $OUTPUTFILE;
# Get list of distribution lists from the server and iterate through it
for GADLOUTPUT in $(sudo -E -u zimbra /opt/zimbra/bin/zmprov gadl); do
	# Write to file..
	echo -ne "$GADLOUTPUT ->" >> $OUTPUTFILE;
	# Get list of accounts in each distribution list
	for GDLOUTPUT in $(sudo -E -u zimbra /opt/zimbra/bin/zmprov gdl $GADLOUTPUT | grep zimbraMailForwardingAddress | awk '{print $2}'); do
		# Write to file..
		echo -ne " $GDLOUTPUT" >> $OUTPUTFILE;
	echo -ne "\n" >> $OUTPUTFILE;
/usr/local/www/vhost/ · Last modified: 2014/09/01 15:00 (external edit)