LinuxQuestions.org
Register a domain and help support LQ
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 09-26-2007, 03:04 PM   #1
christopher_c
Member
 
Registered: Sep 2007
Posts: 61

Rep: Reputation: 15
Where is mail stored?


Hi everyone,

Seen alot of great info on this site and now have a question of my own.

I recently was asked to migrate a site to a new server including all the mail.

Now, I cant figure out for the life of me where exactly all the mail is stored on the original server. I know they are using SquirrelMail as their web based client to receive the emails.

I gone through a bunch of directories in search for any type of 'mail' but no luck. All i was able to find was some preference files and address books for the accounts. Where exactly is the mail text located?

p.s. Im not sure if i gave enough information, let me know if you need anything else.

- A lost linux newbie,
Chris
 
Old 09-26-2007, 04:48 PM   #2
marozsas
Senior Member
 
Registered: Dec 2005
Location: Campinas/SP - Brazil
Distribution: SuSE, RHEL, Fedora, Ubuntu
Posts: 1,397
Blog Entries: 1

Rep: Reputation: 64
There are two possibilities:
1) /var/spool/mail ou /var/mail
2) $USER/.maildir ou $USER/Maildir

If you are using postfix, check main.cf ("grep -i home_mailbox /etc/postfix/main.cf").
If it is not set, them /var/spool or /var/mail is the place.

I'm sorry, I don't remember the proper configuration entry in sendmail....
 
Old 09-26-2007, 07:32 PM   #3
christopher_c
Member
 
Registered: Sep 2007
Posts: 61

Original Poster
Rep: Reputation: 15
Hi Marozsas,

Thanks for the reply!

I checked the directories you had suggested and the directories ARE there. Only thing is there is nothing in any of them. Is it possible these are hidden files?(is there a way to see hidden files?)

thanks!
 
Old 09-26-2007, 08:42 PM   #4
rsashok
Member
 
Registered: Nov 2006
Location: USA, CA
Distribution: RedHat, Debian
Posts: 202

Rep: Reputation: 31
To check for hidden files:
ls -la
 
Old 09-27-2007, 09:39 AM   #5
cconstantine
Member
 
Registered: Dec 2005
Distribution: RedHat, Ubuntu
Posts: 101

Rep: Reputation: 15
check 'netstat -nap | grep :143' to locate the process(es) which are listening and using port 143 (the IMAP port in TCP). post what process is on 143 and someone will know where its mailstores are located.
 
Old 09-27-2007, 12:09 PM   #6
christopher_c
Member
 
Registered: Sep 2007
Posts: 61

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by cconstantine View Post
check 'netstat -nap | grep :143' to locate the process(es) which are listening and using port 143 (the IMAP port in TCP). post what process is on 143 and someone will know where its mailstores are located.
seems I get:

Code:
16950/couriertcpd

Im assuming this is running the courier imap server?
 
Old 09-27-2007, 12:22 PM   #7
marozsas
Senior Member
 
Registered: Dec 2005
Location: Campinas/SP - Brazil
Distribution: SuSE, RHEL, Fedora, Ubuntu
Posts: 1,397
Blog Entries: 1

Rep: Reputation: 64
Code:
$ grep MAILDIRPATH /etc/courier/imapd
the variable MAILDIRPATH in the above IMAP configuration file will show you where the user's e-mail are stored, just like cconstantine suggested.

Mine is just ".maildir", a directory on user's home.
 
Old 09-27-2007, 01:27 PM   #8
christopher_c
Member
 
Registered: Sep 2007
Posts: 61

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by marozsas View Post
Code:
$ grep MAILDIRPATH /etc/courier/imapd
the variable MAILDIRPATH in the above IMAP configuration file will show you where the user's e-mail are stored, just like cconstantine suggested.

Mine is just ".maildir", a directory on user's home.
Great, I did the command and got /Maildir.

I went to /Maildir/new/ and listed the directory contents and received a fair amount of files. --->

Code:
homeless:~/Maildir/new# ls
1149127501.Vfd04I168009.homeless.koumbit.net  1174680116.Vfd02Ibc321.homeless.koumbit.net  1182639619.Vfd02Ibcee8.homeless.koumbit.net
1149128402.Vfd04I16800c.homeless.koumbit.net  1174731954.Vfd02Ibc322.homeless.koumbit.net  1182639620.Vfd02Ibcee9.homeless.koumbit.net
1149128747.Vfd04I16800e.homeless.koumbit.net  1174770074.Vfd02Ibc323.homeless.koumbit.net  1182639621.Vfd02Ibceea.homeless.koumbit.net
1149130897.Vfd04I44012.homeless.koumbit.net   1174770079.Vfd02Ibc324.homeless.koumbit.net  1182729615.Vfd02Ibceeb.homeless.koumbit.net
1149131101.Vfd04I44013.homeless.koumbit.net

etc etc...
I opened up some of the files in a text editor and seems like it is the actual mail.

Now the actual plan that I have for these is to transfer them all to a new account on a different server. Is the naming scheme of the files going to affect anything going wrong when I transfer and try to access them?

Thanks for your timely replies!
 
Old 09-27-2007, 01:37 PM   #9
marozsas
Senior Member
 
Registered: Dec 2005
Location: Campinas/SP - Brazil
Distribution: SuSE, RHEL, Fedora, Ubuntu
Posts: 1,397
Blog Entries: 1

Rep: Reputation: 64
You must preserve as much as you can. owners, groups and permissions modes.
How do you plan to move those files ? By a physical backup tape ? By a remote ssh conection ? By a remote mounted directory over NFS ? Let say you will move it using a physical tape:
On the old server, as root:
Code:
# cd /home
# tar -czf /dev/nst0 .
On the new server, as root:
Code:
# cd /home
# tar -xzpf /dev/nst0
 
Old 09-27-2007, 01:59 PM   #10
christopher_c
Member
 
Registered: Sep 2007
Posts: 61

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by marozsas View Post
You must preserve as much as you can. owners, groups and permissions modes.
How do you plan to move those files ? By a physical backup tape ? By a remote ssh conection ? By a remote mounted directory over NFS ? Let say you will move it using a physical tape:
On the old server, as root:
Code:
# cd /home
# tar -czf /dev/nst0 .
On the new server, as root:
Code:
# cd /home
# tar -xzpf /dev/nst0

When you say I must preserve 'owners,groups,permission modes', is this easily done? There are approximately 2000 email accounts right now.

I wasnt too sure how I was going to go around this, but the plan was to somehow tar them and then download the file and then reupload and extract onto the new server via ssh.

Am I getting in way over my head here? :P

edit: was doing some searching and seemed to have found that the command "cp -p" will save all the persmission etc. Correct?

Last edited by christopher_c; 09-27-2007 at 02:28 PM.
 
Old 09-27-2007, 02:35 PM   #11
marozsas
Senior Member
 
Registered: Dec 2005
Location: Campinas/SP - Brazil
Distribution: SuSE, RHEL, Fedora, Ubuntu
Posts: 1,397
Blog Entries: 1

Rep: Reputation: 64
Quote:
Originally Posted by christopher_c View Post
When you say I must preserve 'owners,groups,permission modes', is this easily done? There are approximately 2000 email accounts right now.
The "p" flag of tar in extract mode stands for "preserve". So, yes, it is easily done, as you use the "p" flag.

You must have the same UID/GID on both systems, as tar uses the UID/GID, not user/group names. The easy way is to copy the user section from /etc/passwd , /etc/shadow and /etc/group and paste on the new system.

Quote:
Originally Posted by christopher_c View Post
I wasnt too sure how I was going to go around this, but the plan was to somehow tar them and then download the file and then reupload and extract onto the new server via ssh.
If you have root access over ssh, you can use something like this:
On old system:
Code:
# cd /home
# tar -czf - . | ssh root@newserver "cd /home; tar -xzpf -"
double check everything, before you type and after the commands ends, to be sure you done the job right.

good luck !

PS: Pay attention to not overwrite user's home directories ! If you already have a user johndoe on BOTH systems, the above command will overwrite the johndoe's home directory on the new server !

Last edited by marozsas; 09-27-2007 at 02:38 PM.
 
Old 09-27-2007, 03:21 PM   #12
christopher_c
Member
 
Registered: Sep 2007
Posts: 61

Original Poster
Rep: Reputation: 15
Everything is finally starting to come together!

Just a few more questions(if you dont mind hehe)...

I checked out directory /etc/ and checked out /etc/group and /etc/passwd, but for some reason I didnt have /etc/shadow. Any idea why? Does it pose a problem? :|

Also, I mentioned before that there are approximately 2000 mail user accounts. I assumed that there would also be that many actual linux user accounts. I used the following command to get a list of all user accounts on the current system and got the following :
Code:
homeless:/etc# cat /etc/passwd | cut -d":" -f1
root
daemon
bin
sys
sync
games
man
lp
mail
news
uucp
proxy
www-data
backup
list
irc
gnats
nobody
Debian-exim
mysql
postfix
bind
ftp
koumbit
sshd
brett
julien
I noticed there is a 'mail' user. Does this one user govern all the mail? Am i on the wrong track?

Thanks again

Last edited by christopher_c; 09-27-2007 at 03:29 PM.
 
Old 09-27-2007, 03:43 PM   #13
marozsas
Senior Member
 
Registered: Dec 2005
Location: Campinas/SP - Brazil
Distribution: SuSE, RHEL, Fedora, Ubuntu
Posts: 1,397
Blog Entries: 1

Rep: Reputation: 64
Quote:
Originally Posted by christopher_c View Post
I checked out directory /etc/ and checked out /etc/group and /etc/passwd, but for some reason I didnt have /etc/shadow. Any idea why? Does it pose a problem? :|
Not at all, it was a installation time decision to not use shadow passwords. In this case, the second field in a password entry is not a "x" but a cryptografic form of user password.

Quote:
Originally Posted by christopher_c View Post
Also, I mentioned before that there are approximately 2000 mail user accounts. I assumed that there would also be that many actual linux user accounts. I used the following command to get a list of all user accounts on the current system and got the following :
Is this the complete list ? I hope no.
If it is, than I don't known where are the user's database. May be a LDAP server ?

Quote:
Originally Posted by christopher_c View Post
I noticed there is a 'mail' user. Does this one user govern all the mail?
It should be a administrative user which is used to own an e-mail-related program. Use the following code to find files owned by this user on the old server:
Code:
# find / -user mail
 
Old 09-27-2007, 03:59 PM   #14
christopher_c
Member
 
Registered: Sep 2007
Posts: 61

Original Poster
Rep: Reputation: 15
Quote:

Is this the complete list ? I hope no.
If it is, than I don't known where are the user's database. May be a LDAP server ?
Yep that is the complete list =/
Hmm im going to have to dig around to see where the accnts are located



Quote:
Originally Posted by marozsas View Post
It should be a administrative user which is used to own an e-mail-related program. Use the following code to find files owned by this user on the old server:
Code:
# find / -user mail
got the following:
homeless:/# find / -user mail
find: /proc/29799/task/29799/fd/4: No such file or directory
find: /proc/29799/fd/4: No such file or directory
 
  


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
accessing Evolution stored mail via http coontie Linux - Software 0 08-13-2007 10:18 AM
some mails stored in mail queue sunhui Linux - Software 1 06-19-2007 01:17 PM
How to foward stored mail ngwasuma Linux - Software 0 06-01-2007 09:05 AM
with the linux proxi, backend pop3 mail client can not receive mail and send mail rubin823 Linux - Networking 0 12-21-2006 11:06 PM
Change location where mail is stored linuxboy69 Linux - Software 1 04-27-2004 04:45 PM


All times are GMT -5. The time now is 07:57 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration