How to remove old maildir files after upgrade?

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,267
463
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.
 

WebHostPro

Well-Known Member
PartnerNOC
Jul 28, 2002
1,727
28
328
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.
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,267
463
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.
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.
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,267
463
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.
 

did-vmonroig

Well-Known Member
Feb 6, 2012
73
5
58
cPanel Access Level
Root Administrator
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.
Hello.

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

ilanh

Registered
Mar 18, 2005
4
0
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.
 

mfigge

Member
Apr 24, 2007
8
0
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?
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,267
463
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?
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.