migrating kmail between systems

On some systems mail is found under $HOME/.Mail, on some others under $HOME/Mail and – yet on others – I’ve found it even under $HOME/.kde/share/apps/kmail. Regardless of where the source (to be copied from) directory of email is, the important thing is to have the variable “folders”, from $HOME/.kde/share/config/kmailrc point to the target directory.

The only method I have found reliable to migrate directories and files has been by using rsync w/ssh & tar, combined. Assuming that in our case the <source> email directory is /home/user/.Mail, and that the <target> directory we choose is /home/user/.kde/share/apps/kmail the followings are necessary steps to produce a functional kmail <target> system:

<target>/home/user/.kde/share$ rsync -avze ssh user@<source>:/home/user/.Mail/ ./apps/kmail

NOTE: it is important to have the <source> directory ending with a trailing “/”, to be able to copy just the content of it on the <target> one. For the <target> directory having a trailing “/”, or not, makes no difference!

<target>/home/user/.kde/share$ rsync -avze ssh user@<source>:/home/user/.kde/share/apps/kmail/ ./apps/kmail

NOTE: the above needs to be done, because the <…>kmail directory always contains info, even if the mail was not residing there (such as account:@host:port for various pop accounts, autosave info, etc.)

<target>/home/user/.kde/share$ rsync -avze ssh user@<source>:/home/user/.kde/share/config/kmailrc* ./config/

NOTE: the above copies all versions of configuration files, but the really important one is kmailrc, so the command above may be used w/out the wildcard (*)

<target>/home/user/.kde/share$ rsync -avze ssh user@<source>:/home/user/.kde/share/apps/kabc/ ./apps/kabc

NOTE: the above copies the address-book(s) (std.vcf + associated files)

<target>/home/user/.kde/share$ rsync -avze ssh user@<source>:/home/user/.kde/share/config/emailidentities ./config/

NOTE: the above copies all email identities you (may) have configured to use with kmail (usually associated with multiple accounts, of course)

<target>/home/user/.kde/share$ vi ./config/kmailrc ==> make sure you have the line:

folders = $HOME/.kde/share/apps/kmail

That’s it!

P.S. If deciding to use the above method to continuously backup kmail, instead of just migrating it from one system to another, then add a –delete option to the rsync command