I suggest using the MacSonik IMAP Backup Tool you can simply back up emails from the IMAP Server to multiple file formats such as PST, PDF, MBOX, EML, EMLX, MSG, CSV, DOC, DOCX, etc. It removes duplicate emails based on To, From, Date, and Subject. You can move IMAP mailboxes to Office 365, Gmail, Exchange Server, IMAP, etc. with the help of this tool. Other benefits include avoiding duplicate emails and freeing up server space following the creation of an IMAP email backup. The demo version of this tool helps to convert 50 emails per folder. This tool can run smoothly on all major and minor versions of Mac OS.