LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-06-2005, 04:10 AM   #1
RaiReg
Member
 
Registered: Jul 2003
Location: Bali, Indonesia
Distribution: SuSE, Ubuntu, Kubuntu, Mepis, Mandrake, Knoppix, Slax
Posts: 50

Rep: Reputation: 15
Post Backup and restore Kmail


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.
 
Old 09-09-2005, 05:41 PM   #2
archtoad6
Senior Member
 
Registered: Oct 2004
Location: Houston, TX (usa)
Distribution: MEPIS, Debian, Knoppix,
Posts: 4,727
Blog Entries: 15

Rep: Reputation: 234Reputation: 234Reputation: 234
Simpler way

Execute the following code blocks in root terminals: KMenu | System | Terminal Program - Super User Mode

1) On the old box, create the .tar:
Code:
USERS=`ls -l /home/ | grep ^d |awk '{print $9}'` 
for U in $USERS ; do tar -rvvf mail.tar /home/$U/Mail/*; done
Feel free to change the 'tar' options & filename.

2) Transfer the .tar to the new box. (Your choice of method.)

3) On the new box, untar
Code:
tar -xf mail.tar
I can't check this w/o risking trashing my system

4) On the new box, change the directory names:
Code:
USERS=`ls -l /home/ | grep ^d |awk '{print $9}'`  
OLD="Mail"
NEW=".kde/share/apps/kmail/mail/"
for U in $USERS;      
do mkdir -p /home/$U/$NEW; 
cp -r /home/$U/$OLD/* /home/$U/$NEW; 
done
This one, probably the most important, I tested thoroughly on 2 test acct. YMMV.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
backup / restore 5pints Linux - Software 2 01-11-2005 10:08 AM
Backup and restore? tradewind Red Hat 2 07-02-2004 11:18 PM
backup and restore using tar AZDAVE Linux - General 6 11-28-2003 09:40 PM
RH 7.3 Backup and Restore MrJoshua Linux - General 1 06-18-2003 12:39 PM
how to backup/restore kmail? pmaloney Linux - Software 3 08-23-2002 06:04 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:54 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration