Newsroom Update

Beginning in May, a special Today at Apple series titled “Made for Business” will offer small business owners and entrepreneurs free opportunities to learn how Apple products and services can support their growth and success. Learn more >

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

How to move mail data + db to external RAID volume

I need to move the maildata from a OS X 10.4 server (both the database as well as the actual data) to an xraid.

Since mail is very critical to not have working I'd like to make sure I am using the best procedure for the job as well as using a method that is as non-destructive as possible (by this I mean that future Apple sw-updates should not be "disturbed" by the change).

*Can I:*

1. Stop the mailservice

2. Use mailbfr to create a fresh backup copy
NB.: mailbfr is already running daily via cron

3. Move (well actually copy) using cp, ditto or rsync
/var/imap TO /Volumes/xraid/mail/imap
/var/spool/imap TO /Volumes/xraid/mail/spool/imap




4. Change the pointers via Server Admin GUI (or edit the relevant conf file with vi)
/var/imap TO /Volumes/xraid/mail/imap
/var/spool/imap TO /Volumes/xraid/mail/spool/imap

5. Start the mailservice

6. Test that everything works



*HOW TO Maintain high uptime*
Since the copying takes a very long time (there is a gazillion messages and it an old slow G4 server) I would like to know if this would work:

A. Copy /var/spool/imap TO /Volumes/xraid/mail/spool/imap with cp

After testing the procedure (step 1-6 above) then

B. Stop the mailservice

C. Copy the last changes from /var/spool/imap TO /Volumes/xraid/mail/spool/imap with rsync

D. Copy the database from /var/spool/imap TO /Volumes/xraid/mail/spool/imap

E. Change the pointers in Server Admin (same as step 4. above)

F. Start the mailservice (same as step 5. above)

iMac 24" and a lot more, Mac OS X (10.5.2)

Posted on Feb 14, 2008 8:17 AM

Reply
14 replies

Feb 14, 2008 8:46 AM in response to Thomas von Eyben

That could work except for step D. which should be:
D. Copy the database from /var/imap TO /Volumes/xraid/mail/imap

There is a chance though for things getting out of sync.

Assume the following scenario:

Old drive contains a message which gets copied to new drive in step 3.
After it was copied, user deletes this message on the old drive.
Now when you rsync the mailstore and copy over the database things can go potentially out of sync.

Best case, you are fine.
Slight chance of having to rebuild a few single users.
Unlikely, but possible, that you need to rebuild the database (in which case you'd just roll back and start again).

Obviously, I don't know how long copying takes, how many users you have etc., so your mileage may vary.

Feb 14, 2008 11:03 AM in response to pterobyte

I assume* that rsync can make the two directories identical, so in the case you described the rsync command I will create should both copy the new files to the new location as well as delete the file(s) that no longer exists in the original location.



Copying (time taken from the last time I cloned the OS disk) is several hours
- There's roughly 70 GB of maildata
- The number of e-mails is ca. 400.000
- The number of users is ca. 250

I dont think that the server is performing as good as it should (it's being replaced with an intel-based server very soon).
I had to reconstruct the db yesterday (using mailbrf ;-)! and it took ca. 7 hours.
Today the mailque grew to ca. 300 mails for a long time (ca. 6 hours), another issue I need to debug, after working time ended (a coinsidence?) the mailque was empty again…




(*) I still need to test rsync, so far I have not used it, but from man rsync:
+--delete delete files that don't exist on sender+

Feb 15, 2008 6:50 AM in response to pterobyte

After doing the above on my testserver (not the rsyncing part, just the move to external disk part) it was working OK.

BUT then I renamed /var/imap/ to /var/imap_old and the things stopped working.
After I undid the rename I still have problem, the problem is related to a socket. The error I get is:
…status=deferred (temporary failure. Command output: couldn't connect to lmtpd: No such file or directory_ 421 4.3.0 deliver: couldn't connect to lmtpd_ )

I can see that the file /var/imap/socket/lmtp exists and that the timestamp indicates that the file is being recreated eg from a server reboot (and probably also on a service stop+start

server:~ admin$ ls -l /var/imap/socket/lmtp
srwxrwxrwx 1 root mail 0 Feb 15 15:35 /var/imap/socket/lmtp

I think I did the renaming while the mailservice was running (since I thought that the files were not used) that might mean something.


I tried mailbfr -o hoping that it might have been a permission problem, but it was'nt so that did'nt help.

I then hoped that the socket would be recreated from a reboot, this is also not the case.

I don't know a lot about sockets, and have a problem getting the service back in working order.

I can see that the mails are now piling up in the queue, using postqueue -p.
Here I am getting the same error:

(temporary failure. Command output: couldn't connect to lmtpd: No such file or directory_ 421 4.3.0 deliver: couldn't connect to lmtpd_)

Feb 15, 2008 7:11 AM in response to pterobyte

I did step 1-6 as described earlier and hence did not rename the database while running (knowing that WILL cause problems).

I am currently able to both read my previously received mail (as well as send new mail) so the database is OK it seems


AFTER all was changed and was working I thought I'd make sure nothing was being used from the old location and THEN I found out there is something still being used
(/var/imap/socket/lmtp).

Do you still think it's necessary to do a reconstruct - I really think that something else must be wrong!

Feb 15, 2008 7:35 AM in response to pterobyte

Correct I changed the paths in imapd.conf
FROM:
configdirectory: /var/imap
partition-default: /var/spool/imap

TO:
configdirectory: /Volumes/Data/Mail/imap
partition-default: /Volumes/Data/Mail/spool/imap


I try to teach myself to be able to do as much server-maintenance as possible via CLI - a real benefit when you're not even able to contact the server via Server Admin (due to other problems 🙂


😉

Feb 15, 2008 8:00 AM in response to Thomas von Eyben

OK - Heres my complete guide (what I googled for but did not find 😉


How to move the mailstorage to another volume (/Volumes/Data)
Based upon Mac OS X Server 10.4.11

1. Stop mailserver
sudo serveradmin stop mail




2. Create backup with mailbfr ( http://osx.topicdesk.com/content/view/41/41/)
sudo /usr/sbin/mailbfr -b /Volumes/Data/Backups/mailbfrBackups --mode incremental




3. Create the new location
mkdir -p /Volumes/Data/Mail/spool/imap
mkdir -p /Volumes/Data/Mail/imap




4. Copy the data to the new location
sudo cp -Rpv /var/spool/imap/ /Volumes/Data/Mail/spool/imap/
sudo cp -Rpv /var/imap/ /Volumes/Data/Mail/imap/




5. Backup relevant configuration files
sudo cp /etc/imapd.conf /etc/imapd.conf_TvE-2008.02.15
sudo cp /etc/cyrus.conf /etc/cyrus.conf_TvE-2008.02.15
sudo cp /etc/postfix/main.cf /etc/postfix/main.cf_TvE-2008.02.15




6. Change the pointer to the new location in /etc/imapd.conf
configdirectory: /Volumes/Data/Mail/imap
partition-default: /Volumes/Data/Mail/spool/imap




7 Change the pointer to the new location in /etc/cyrus.conf
lmtpunix cmd="lmtpd" listen="/Volumes/Data/Mail/imap/socket/lmtp" prefork=0
# notify cmd="notifyd" listen="/Volumes/Data/Mail/imap/socket/notify" proto="udp" prefork=1




8. Change the pointer to the new location in /etc/postfix/main.cf
virtual_transport = lmtp:unix:/Volumes/Data/Mail/imap/socket/lmtp




9. Rename old mail dirs to make sure they're not used
- Optional step - the content should be erased to free up space and avoid confusion)!
sudo mv /var/imap/ /var/imap_old-TvE-2008.02.15
sudo mv /var/spool/imap/ /var/spool/imap_old-TvE-2008.02.15




10. Start mailserver
sudo serveradmin start mail




One should now also create fresh backup using mailbfr, so a restore will restore to a point in time AFTER all the above changes have been done.





- Thomas von Eyben (Credits to pterobyte/ http://topicdesk.com/ !)

Message was edited by: Thomas von Eyben

How to move mail data + db to external RAID volume

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.