Glenno-Notes
- This article is NOT official Zimbra documentation. It is a user contribution and may include unsupported customizations, references, suggestions, or information. |
Bulk delete items from all users matching query via zmmailbox
Suppose you have the following scenario:
- We have an administrative assistant who left the company (admin_assistant@example.com). She had created reoccurring appointments on several people's calendars which now cannot be removed. Restoring the administrative assistant's account is not an option since she was removed a while back and our oldest backup doesn't contain her account. Any suggestions on how to remove the appointments?
As an administrator, you can script zmmailbox to search all accounts for appointments with an organizer of admin_assistant@example.com, and then delete those appointments.
#!/bin/bash
# tested on ZCS 6.0.8
if [ `whoami` != "zimbra" ]; then
echo "You must be the zimbra user to run this script."
exit 0
fi
# change query below to what you want to match
# the example searches for a body matching "Organizer: admin_assistant@example.com"
query="\"\\\"Organizer: admin_assistant@example.com\\\"\""
# change to search the type of items you want to match
# types are: message,conversation,contact,appointment,document,task,wiki
type="appointment"
for acct in `zmprov -l gaa`
# if you want to search specific accounts, use the for loop below
# for acct in "99@test2.test" "100@test2.test" "101@test2.test" "102@test2.test" "103@test2.test"
do
echo "Searching account $acct..."
ITEMS=`zmmailbox -z -m $acct search -t $type "$query" | awk '{ if (NR>4 && NF) {print $2}}' | tr '\n' ,`
if [ -n "$ITEMS" ]; then
echo " Deleting item(s) " $ITEMS
# Remove echo after verifying the search results
echo zmmailbox -z -m $acct di $ITEMS
fi
done
Credit to: King0770-Notes-Removal_of_Bad_Contact_Address
Deciphering zmstat charts
MySQL: InnoDB Buffer Pool Hit Rate
In general, should stay above 995.
Bad
Better
Ideal
Mailboxd: Minor Garbage Collection Time and Mailboxd: Major Garbage Collection Time
If the GC time starts getting over a few percent, especially repeatedly, then it's something that users will notice.