Migrate Kmail local folders

No doubt many have done this before but it’s not obvious to me.

I want to migrate specific folders in local folders to a new machine.
The PIM data exporter appears to do this but doesn’t have the resolution to export specific folders, and I don’t want to overwrite my new configuration.

Should I archive each folder, transfer the resultant compressed archive to the new machine? Does import work with compressed folders and if so can they be decompressed inside Kmail?


First – Hello and welcome to the KDE Discuss forums.

The FileArchive Folder… method is the better method – the PIM Data Exporter is really only meant to be used to export your KMail settings and, the settings of other PIM components.

What I’ve found to be most reliable method of archiving and restoring KMail local folders is to archive the folders in the first place – I use KMail’s Automatic Archiving tool to have a regular backup of my Folders – including IMAP folders …
But, if I’m migrating my KMail environment, I archive before beginning the migration – just to make sure …
Then, at the target machine, I create a new local Mail-Dir Folder which is physically located as a directory in ‘~/.local/share/’ – the name of the new local Mail-Dir Folder is, “Imports” …

I then import the Archive Backup to the new local folder and, copy the imported Local Folders over to their “normal” location in “Local Folders” …

  • Why not simply import to “Local Folders” ?
    I have found that importing to a parallel local folder and then copying the e-Mails to where they should be located to be more reliable.
    Moving the imported e-Mails over to their “normal” local Folders location is also sometimes plagued by annoying little issues reported by “akonadictl fsck” …

More information here: <https://docs.kde.org/stable5/en/kmail/kmail2/dealing-with-dirt.html>

BTW, I use the following CLI command to track the health of the Akonadi databases:

> akonadictl fsck 2>&1 | grep -iE 'found|no RID'

Took me a while to get back to this, but thanks.

I transferred sub folders and once I worked out the subfolder convention it worked nicely. The structure’s shown below

I guess the archiving process could be bypassed and the relevant folders transferred between machines

A neat technique