Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

How to remove old maildir files after upgrade?

Discussion in 'E-mail Discussion' started by WebHostPro, Jul 7, 2017.

Tags:
  1. WebHostPro

    WebHostPro Well-Known Member
    PartnerNOC

    Joined:
    Jul 28, 2002
    Messages:
    1,654
    Likes Received:
    15
    Trophy Points:
    318
    Location:
    LA, Costa RIca
    cPanel Access Level:
    Root Administrator
    Twitter:
    Hi,

    I've changed my server email to MDBOX. And chose the option to leave the old email in case of an error during the transition. Now that I have MDBOX working. How can I remove the old emails that used MAILDIR?

    Thank you for your help.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  2. cPanelMichael

    cPanelMichael Technical Support Community Manager
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    44,802
    Likes Received:
    1,896
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    Hello @WebHostPro,

    You can delete the old email by running the conversion script again, but with the "--delete-old-format" flag. EX:

    Code:
    /usr/local/cpanel/scripts/convert_maildir_to_mdbox --user=$username --delete-old-format
    Thank you.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. WebHostPro

    WebHostPro Well-Known Member
    PartnerNOC

    Joined:
    Jul 28, 2002
    Messages:
    1,654
    Likes Received:
    15
    Trophy Points:
    318
    Location:
    LA, Costa RIca
    cPanel Access Level:
    Root Administrator
    Twitter:
    Well, that's easy. Thanks!
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
    cPanelMichael likes this.
  4. WebHostPro

    WebHostPro Well-Known Member
    PartnerNOC

    Joined:
    Jul 28, 2002
    Messages:
    1,654
    Likes Received:
    15
    Trophy Points:
    318
    Location:
    LA, Costa RIca
    cPanel Access Level:
    Root Administrator
    Twitter:
    Sorry just ran the code:

    /usr/local/cpanel/scripts/convert_maildir_to_mdbox --user=$username --delete-old-format

    And it just pulls up the help files for the convert_maildir_to_mdbox script. Like something is missing.

    I am trying to do this for the whole server not jut one account or email. I assume the error is because it wants a username.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  5. cPanelMichael

    cPanelMichael Technical Support Community Manager
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    44,802
    Likes Received:
    1,896
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    This script is only usable on a per-account or per-email-account basis. I suggest running the command with a single cPanel account to verify it works as expected. You could then run a custom bash command that loops all cPanel users to the script if you'd like to run it on all accounts. Let me know if you need any help with this.

    Thank you.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  6. WebHostPro

    WebHostPro Well-Known Member
    PartnerNOC

    Joined:
    Jul 28, 2002
    Messages:
    1,654
    Likes Received:
    15
    Trophy Points:
    318
    Location:
    LA, Costa RIca
    cPanel Access Level:
    Root Administrator
    Twitter:
    Yeah, that's tricky.

    Can I convert it back to maildir and then back to mdbox without choosing to save the old email files. Is it risky to convert it back to mail dir?

    Odd they would have the option to save old files but not a way to remove them via batch.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  7. cPanelMichael

    cPanelMichael Technical Support Community Manager
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    44,802
    Likes Received:
    1,896
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    Hello,

    Yes, you can convert the mailboxes back to the Maildir format, and then convert to the Mdbox format again with "Keep old mailbox files." unchecked. I confirmed this works as expected on a test system, but account backups are always recommended in-case something goes wrong during the conversion process (e.g. drive failures, network/connection issues).

    Thank you.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  8. did-vmonroig

    did-vmonroig Active Member

    Joined:
    Feb 6, 2012
    Messages:
    40
    Likes Received:
    0
    Trophy Points:
    56
    cPanel Access Level:
    Root Administrator
    Hello.

    If I understand correctly, if the user mailboxes are already in mdbox format, this just deletes old maildir backup, isn't it?
     
  9. cPanelMichael

    cPanelMichael Technical Support Community Manager
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    44,802
    Likes Received:
    1,896
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    Yes, that is correct.

    Thank you.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
    did-vmonroig likes this.
  10. ilanh

    ilanh Registered

    Joined:
    Mar 18, 2005
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    226
    Just for convenience, here is a script that removes all backups from all users:

    Code:
    #!/bin/bash
    cd /var/cpanel/users
    for user in *
    do
       /usr/local/cpanel/scripts/convert_maildir_to_mdbox -user=$user -delete-old-format
    done
    FYI, the quota usage is doubled for all users after conversion if you choose to keep old format as backup.
     
  11. mfigge

    mfigge Registered

    Joined:
    Apr 24, 2007
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    151
    I converted several accounts on the server using WHM interface, keeping the old files.
    As everything seems ok, can I run the process again in WHM to delete the old files? Or I should do it on the command line?
     
  12. cPanelMichael

    cPanelMichael Technical Support Community Manager
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    44,802
    Likes Received:
    1,896
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    Hello,

    You will need to use the command line if you've already converted the mailboxes for the accounts, as WHM will only list accounts that have not yet been converted to the mdbox format.

    Thank you.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice