Cannot import mails from oldserver mailbox folder to newserver mailbox folder solution urgently needed

SYSTEM INFORMATION
OS type and version Ubuntu 22.04
Webmin version 2.1.05
Virtualmin version 7.90 Pro
Related packages CORE VIRTUALMIN

This is the utility I am using.

copy-mailbox
Copy mail from one location to another, perhaps converting formats.

The source mail is specified with the --source flag, and the destination with the --dest parameter. Both must be followed by a full path, which can end with a / to indicate that it is in Maildir format.

By default email is just coped, but the --delete flag can be given to have it moved instead.

Command Line Help
virtualmin copy-mailbox --source file
–dest file
[–delete]

I have a backup of mail in a standard maildir format from the old hosting.

Folder structure is /tmp/user.name and has all the expected /new /cur etc. folders in it.

Destination is on the current server /home/domain/homes/user.name/maildir/.INBOX.subfolder/

command is:

virtualmin copy-mailbox --source /tmp/user.name/ --dest /home/domain/homes/user.name/maildir/.INBOX.subfolder/
Copying 16 messages totalling 24.02 MiB ...

Seems to copy email but I have no idea where that email went. It is not in the destination mailbox or anywhere else I can find!

Can you advise please as I need to import the mail backups into the new server.

Cheers
Spart

Are the moved files owned by the mailbox owner or the user that moved the files (e.g root) ? Use something like

ls -l
command in each user maildir to see who owns what

The emails that were copied from the maildir do get put under the /cur directory in the dest mailbox however they are owned by root:root not to useful.

Even after sorting permissions. The imported mails are not complete and have no content or subject.

Just a bunch of useless nosubject empty mails.

Currently looking at other solutions to this but not finding much TBH. doveadm is super confusing!

Cheers
Spart

how did you sort the permissions ? did you just use chown or did you use chmod ?

For completeness this is a new client and all he got was a backup file from his hosting company. We were able to restore/convert his WP website but cannot at present restore mail.

Cheers
Spart

Both!

Cheers
Spart

you were in /home/domain/homes and did ‘chown -R user:user userdir’ this just ensures all the files (indexs etc) are owned by the correct user, but I guess you did that

Currently exploring doveadm but not having much luck.

I manged to get the doveadm command working but it produces the same output. Essentially I get a bunch of imported useless mails. Without the permission problem so no need to change permissions on the disk. The emails imported have no mail info in them subject to from etc.

This command works and processes the oldmaildir importing all mail.
doveadm -Dv -o maildir_broken_filename_sizes=yes import -u user.name maildir:/tmp/oldmaildir "" all

Cheers
Spart

and the files you are restoring are all ok or is there a problem there ? TBF I have done the job your doing loads of times & have never hit any problems with the exception of file permissions and have never needed doveadm command

What files? You mean the original backup files? They seem fine.

Cheers
Spart

I’m at a loss then however this is how I do it
the import looks like this
image
so then

service postfix stop && service dovecot stop

stops the mail services

cp -r /tmp/backup /home/domain/homes/user

that copies the files

chown -R user:user /home/domain/homes/user

change the user to the correct user

ls -lhR /home/domain/homes/user

check that everything looks good if it is

service postfix start && service dovecot start

that restarts the services
just wondering if this is a different version of dovecot causing this IDK

Thank you for the note and for the assistence.

Yeah this is not the same as the original backup came from another hosting provider. They obviously used dovecot as the .dovecot files are in the maildirs.

The new users are all functional on the new Vmin hosting. But I cannot get their old mail imported.

I created a new imported@domain user for testing this. As stated the emails are imported using both processes doveadm or virtualmin copy-mailbox (with permission setting) but the resulting emails are useless as they contain no useful data from to subject and no content etc.

Cheers
Spart

I have a script I used for importing from Webuzo. It is almost all documentation. It gets the new permissions from the current account and then rsyncs them over. It is heavy on documentation but I’m not a script guy so I already am confused by how I came up with some of it. :wink: Note the ‘money line’ is the last line and commented out. There is an rsync dry run line that is the default. I think nothing else in the script does any writes. It just gets the current user permissions to use for the sync.

But note, I did all this before firing up the new service to the end user. I think it left the default account creation email so it doesn’t clobber current content. But, check that if you use this.

EDIT: Looking at this, Virtualmin doesn’t store the dovecot files in the home directory by default. I had to change the default in the interface somewhere. Could this be a problem of the dovecot files not being where the current system is looking for them?

(temp link removed)

You are importing from the old service. Which does not exist anymore.

If I had access to the old service. imapsync to the rescue! But all I have are the old maildir backups from the old hosting.

Cheers
Spart

So you haven’t just copied the whole structure over then ? I would give it ago

I cannot do that as the client is live on the service with users. They have email in their accounts.

Plus I have no idea what the config of the original dovecot was. All I have are the maildir backups which on face value look to be complete filesystem backups.

Cheers
Spart

You didn’t turn off postix and dovecot before you started ? What happens if procmail drops mail into the maildir while you are importing I would guess corrupted files … however i will try my method without turning off postfix/dovecot. I have an account that has 6.5 gb of mail … I’ll try that one see how it goes

using doveadm should stop any issues like that.

Also the email account I am using for testing this is an empty account. SO any corrupted imports do not affect the live clients.

Cheers
Stephen

I imported the old mail directories and then used that script to sync them up.

Again, Virtualmin doesn’t, or didn’t when I did this, store the config files in the home directory. Is it possible you may need to ‘re-index’ to get the old, imported emails into the current structure?

The structure of the old maildir folders and the new ones is the same. Looks like the old hosting was using cpanel and dovecot.

doveadm which is what the virtualmin copy-mailbox command is using without any -u or -U parameters imports the mail fine. I get the correct amount of messages etc.

It is just useless when it gets into the new mailbox. The only thing I can think of is that on the old hosting maybe compression was enabled and I am importing compressed messages!

*** I just checked by viewing one of the old email files in the oldmailbox directories. I can read the odd one of the emails. All the information is in there from to subject etc. Not compressed. The majority of the files can be opened but are unreadable. So I have no idea why!*****

Cheers
Spart