Backup and restore Kmail from Mandrake 9.2 to SuSE 9.3
Now I've been using GNU/Linux for several years now but I am no expert and still pretty much a newbie, so I though this would be useful to someone who tried something similar.
Background of the story is that after using Mandrake 9.2 for over a year or so I wanted to switch to SuSE 9.3, but since I am not the only user I had to backup all the data for every user and one of it was all the emails in Kmail. Thing is Kmail doesn't provide a feature to backup or export all the emails but only for the address book (address book can be exported as CSV file and later imported just as easy).
I've been
Googling around and the best I could find out was to backup the whole Kmail - Mail directory including sub directories and restore it later after the installation was done. Simple enough I though since in Mandrake 9.2 all the email a user has are stored in :
/home/user/mail/
So I packed everything into mail.tar.gz done.
Next I installed SuSE 9.3 and after all configuration was done, I started to restore all the data for each user. After configuring Kmail for the 1st user I thought all I need is to restore the emails to /home/user/mail/ and the job is done but no the directory was not there.
Now I don't know if the directory structure is different because of the distro or because of the different Kmail version (in Mandrake 9.2 it was an older one). Anyway turns out that the mail is stored in :
/home/user/.kde/share/apps/kmail/mail/
...
... hidden directory that of course doesn't show in GUI file manager
So what to do
First of all the directories that I needed to restore were inbox and sent-mail, nothing else. So I created a temporary folder in home directory naming it
transfer and then using konqueror file manager restored only files in /home/user/mail/inbox/cur/ directory.
Next I jumped to console logged in as
root and run
mc (midnight commander), in mc left panel I browsed to
/home/user/transfer/ directory and then with the right panel browsed to
/home/user/.kde/share/apps/kmail/mail/inbox/cur/ then back to left panel selecting all of the files in it and then copying it to the right panel and wham all of the inbox was restored. Of course I open Kmail to verify this and it was there
After deleting all files in
/home/user/transfer/ directory I repeated the same thing for the files in
/home/user/mail/sent-mail/cur/ and copied all the files to
/home/user/.kde/share/apps/kmail/mail/sent-mail/cur/.
Of course I had to repeat this steps for every user but since it achieved the goal it it didn't really matter.
I don't know if this would be done the same way in another distro because I guess there is always a possibility of a different directory structure but it should be more or less the same.
I'm also sure that there must be a simpler/shorter way to do this so if anyone knows it please share it with the rest of us. Perhaps the restoring part can be done by directly sending files to the /home/user/.kde/share/apps/kmail/mail/ if so maybe someone could share how to do that with newbies in mind
For anyone who found this useful please drop a note or comment here.