King0770-Notes-Remove-Orphaned-Account

Revision as of 22:31, 5 December 2018 by King0770 (talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Due to reasons beyond our control, you may find a ghost account, or commonly referred to as a orphaned account.
Example

zmblobchk start
[] INFO: Setting mysql connector property: maxActive=100
[] INFO: Setting mysql connector property: maxActive=100
....
Checking mailbox 143.
no such account: 134a36d6-acf2-4287-80d3-f8d83e2be674

MariaDB [zimbra]> select * from mailbox where account_id="134a36d6-acf2-4287-80d3-f8d83e2be674"\G
*************************** 1. row ***************************
id: 143
group_id: 43
account_id: 134a36d6-acf2-4287-80d3-f8d83e2be674
index_volume_id: 2
item_id_checkpoint: 256
contact_count: 0
size_checkpoint: 0
change_checkpoint: 1
tracking_sync: 0
tracking_imap: 0
last_backup_at: NULL
comment: johm.smith@example.com
last_soap_access: 0
new_messages: 0
idx_deferred_count: 0
highest_indexed: NULL
version: 2.7
last_purge_at: 0
itemcache_checkpoint: 0
1 row in set (0.00 sec)

zmprov gmi johm.smith@example.com
ERROR: account.NO_SUCH_ACCOUNT (no such account: johm.smith@example.com)

In our example, the account address of johm.smith@example.com with the mailbox_id of 143 now needs to be removed from mysql.

mysql mboxgroup43 -e "delete from appointment where mailbox_id='143';"
mysql mboxgroup43 -e "delete from appointment_dumpster where mailbox_id='143';"
mysql mboxgroup43 -e "delete from data_source_item where mailbox_id='143';"
mysql mboxgroup43 -e "delete from imap_folder where mailbox_id='143';"
mysql mboxgroup43 -e "delete from imap_message where mailbox_id='143';"
mysql mboxgroup43 -e "SET FOREIGN_KEY_CHECKS=0; delete from mail_item where mailbox_id='143';"
mysql mboxgroup43 -e "delete from mail_item_dumpster where mailbox_id='143';"
mysql mboxgroup43 -e "delete from open_conversation where mailbox_id='143';"
mysql mboxgroup43 -e "delete from pop3_message where mailbox_id='143';"
mysql mboxgroup43 -e "delete from purged_conversations where mailbox_id='143';"
mysql mboxgroup43 -e "delete from purged_messages where mailbox_id='143';"
mysql mboxgroup43 -e "delete from revision where mailbox_id='143';"
mysql mboxgroup43 -e "delete from revision_dumpster where mailbox_id='143';"
mysql mboxgroup43 -e "delete from tag where mailbox_id='143';"
mysql mboxgroup43 -e "delete from tagged_item where mailbox_id='143';"
mysql mboxgroup43 -e "delete from tombstone where mailbox_id='143';"
mysql zimbra -e "delete from mailbox where id='143';"
mysql zimbra -e "delete from mailbox_metadata where mailbox_id='143';"
mysql zimbra -e "delete from mobile_devices where mailbox_id='143';"
mysql zimbra -e "delete from out_of_office where mailbox_id='143';"
mysql zimbra -e "delete from pending_acl_push where mailbox_id='143';"
mysql zimbra -e "delete from scheduled_task where mailbox_id='143';"
mysql zimbra -e "delete from zmg_devices where mailbox_id='143';"

if [ ! -d /opt/zimbra/store/0/143 ]; then echo "Directory doesn't exist"; else rm -rf /opt/zimbra/store/0/143; fi
if [ ! -d /opt/zimbra/index/0/143 ]; then echo "Directory doesn't exist"; else rm -rf /opt/zimbra/index/0/143; fi

zmmailboxdctl restart

More articles written by me, https://wiki.zimbra.com/wiki/King0770-Notes

Jump to: navigation, search