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/
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!
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.
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
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
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.
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. 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?
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.
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
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!*****