LINUX.IE, website of the Irish Linux Users' Group
Tux rules!

   
Home
New Users
Articles
Download
Projects
Community
Vendors

  Print Version
Email to...
 
Archives:


planetILUG

Recent News

News Archive


Join the
ILUG
on FaceBook


Join the
ILUG
on LinkedIn


Join the
ILUG SETI
Group



















 
 :: Mailing Lists

[ILUG] Script to move Maildir content

[ILUG] Script to move Maildir content

Francis Daly francisdaly at gmail.com
Tue Jul 7 13:44:20 IST 2009


On 07/07/2009, Patrick O'Connor <patrick.oconnor at sysadmin.ie> wrote:

Hi there,

> 1. Just rsync the lot and don't use the maildirs already copied to the new
> server.

I'd use something like that one. If large data transfer is slow and
already done, then you can try moving the data around so that the new
rsync will find and use it.

> Either way I still need a way to link the old usernames to the new and that
> looks like I'll need to use some sort of a table. How would I go about that?

Do it one bit at a time, in a loop.

As has been mentioned, use "rsync" to copy the data from "oldserver"
to "newserver". Write it to a temporary location on the same volume as
the final location, so that "mv" completes rapidly.

You'll need the new and old directory names -- probably the usernames
from your "users" file.

You'll need the new user:group ownerships -- the new username, and
maybe the groupname matches the username, or maybe the groupname is
the same for everyone. Below, I assume group=user.

The tr/read line below needs that no new or old username includes
whitespace or colon. You can verify that in your "users" file before
starting. If it is not the case, some modifications will be needed.

===
#!/bin/sh
src="temporary rsync Maildir location, absolute or relative to here"
dst="final Maildir location, absolute or relative to $src"
users="file containing olduser:newuser pairs, absolute or relative to $src"

cd "$src"
tr : ' ' < "$users" | while read old new; do
 mv $old "$dst"/$new && chown -R $new:$new "$dst"/$new
done
===

Watch for any error output. If, at the end, anything remains in $src,
then the $users file may not have been complete.

You can pick your own level of testing and validating that you can
access the new mailstore as the appropriate users. For the live
cutover, have a recent rsync done; stop the
normal-access-write-processes on the old server, do a fresh rsync
(which should be fast), run the tested script on the new server and
confirm that it worked, then start the normal-access-write-processes
on the new server.

Good luck,

	f



More information about the ILUG mailing list
Read this without the formatting.
                                                                                                    

 

Hosted by HEAnet


Maintained by the ILUG website team. The aim of Linux.ie is to support and help commercial and private users of Linux in Ireland. You can display ILUG news in your own webpages, read backend information to find out how. Networking services kindly provided by HEAnet, server kindly donated by Dell. Linux is a trademark of Linus Torvalds, used with permission. No penguins were harmed in the production or maintenance of this highly praised website. Looking for the Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!
RSS Version
Powered by Dell