Backing up and Restoring your Kmail files/folders -- A simple and unofficial mini-Howto

r bartlett techwritebos at
Fri Apr 7 21:40:08 BST 2006

A very basic Kmail backup and restore mini-HOWTO:

(Disclaimer:  This document is NOT an official FAQ or Howto but people are welcome to use any/all of it as they wish in official or unofficial Kmail docs.  I take no responsibility for any issues/problems/data loss that may occur---and if anyone sees mistakes or typos, please correct them!!)

1.  Backup your entire .kde directory.  I experienced data loss when using a vfat-formatted USB external hard drive, so BE SURE TO VERIFY YOUR BACKUP prior to deleting/overwriting files.  If possible, backup to 2 separate locations on ext2fs filesystems...and (again) VERIFY.  It's better to do an entire .kde directory backup rather than just the files listed below:  you never know when you may need another related file.  This way you'll have them all, should you ever need them.

One easy way to backup is to use "tar," as in:

tar -cvf mykdebackup$(date '+%Y%m%d').tar ~/.kde

(***Note:  This can be done directly to an offsite server...Anyone want to add the line that will do this?***)

This will create a backup file with the year, month, and day attached, as so:


It is a great idea to backup all important files on a regular basis, such as monthly or weekly.  "Cron" can automate this process and make it relatively painless.

(***Note:  Anyone out there want to add a simple backup script with simple instructions for how to make it part of the regularly scheduled 3am tasks?***)

2.  Do your upgrade or reformat or whatever.  (Did you verify your data first?)

3.  When ready to start using Kmail again, restore your backup file by using "tar" again:

tar -xvf mykdebackup20060407.tar

Now you will have two .kde directories, an old an a new, in:


4.  DO NOT START Kmail or Kontact.  Use ps to verify that neither process is running:

ps aux | grep kmail
ps aux | grep kontact

These are the important files you will want to copy:

1.  .kde/share/apps/kmail/mail/  (your email)
2.  .kde/share/config/kmailrc/  (your spam filters)
3.  .kde/share/config/emailidentities (your identities)

5.  Copy them with your method of choice.  Be sure to use the "-r" (recursive) feature so that all folders and subdirectories get copied as well.  For example:

cp -r /home/yourusername/mykdebackup20060407/.kde/share/apps/kmail/mail /home/thesun/.kde/share/apps/kmail

(All of that should be one long line...not sure how it will display on the screen)

6.  Start Kmail.  If you are lucky, all goes well.

7.  If you notice that files listed in the window disappear or change to "Unknown" when you try to open them, go to the .kde/share/apps/kmail/mail directory and look for files which do NOT end in *.index.  Remove the files that contain "*.index.ids" or "*.index.sorted" (be sure to close Kmail first).  

8.  Restart Kmail.  It may take a while for the program to regenerate the ids and sorted indexes, but you should have solved the problem.

9.  If not, post a question to kde at and go from there.

(Again, a disclaimer.   File names and directory structure are sure to change.  This is current KDE included with Fedora Core 5, 3.5.1-2.3 Red Hat, and Kmail v1.9.1.  This document was written on 07 April 2006.  Good luck, and long live the Penguin.)

New Yahoo! Messenger with Voice. Call regular phones from your PC and save big.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>
-------------- next part --------------
This message is from the kde mailing list.
Account management:
More info:

More information about the kde mailing list