Migrate courier and vpopmail to dovecot and vboxadm: Unterschied zwischen den Versionen

Aus crazylinux.de
Zur Navigation springen Zur Suche springen
K (init)
 
(cat)
 
(6 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt)
Zeile 1: Zeile 1:
== dovecot pop3 config ==
<source lang=bash>
protocol pop3 {
  pop3_uidl_format = UID%u-%v
}
</source>
WARNING: Badly done migration will cause your IMAP and/or POP3 clients to re-download all mails. Read this page carefully: http://wiki2.dovecot.org/Migration
== Export User  ==
== Export User  ==


Zeile 9: Zeile 20:
<br>  
<br>  


result is a vboxadm-command. vboxadm needs to be patched to import the crypted password  
result is a vboxadm-command. vboxadm needs to be patched to import the crypted password. Then call [http://wiki2.dovecot.org/Migration/Courier courier-dovecot-migrate.pl] to convert Maildirs (to preserv pop3-uids)


<source lang="bash">vboxadm mailbox add name@domain.de -n 'my name' -cp '{CRYPT}$1$p0cQI5u5$ldfdfdfdfdfma0wLJ.1' --domainadmin 0 -a 1
<source lang="bash">vboxadm mailbox add name@domain.de -n 'my name' -cp '{CRYPT}$1$p0cQI5u5$ldfdfdfdfdfma0wLJ.1' --domainadmin 0 -a 1
vboxadm alias add postmaster@domain 'name@domain.de'</source>  
vboxadm alias add postmaster@domain 'name@domain.de'
/root/courier-dovecot-migrate.pl /home/import_mail/ --recursive --to-dovecot --convert
</source>


== getuser.pl  ==


<source lang="perl">
#!/usr/bin/perl -w
use strict;


== getuser.pl ==
#EDIT
my $base = "/var/vpopmail/domains";


<source lang="perl">#!/usr/bin/perl -w
#rsyc /var/vpopmail/domains to newserver /home/admin/import_mail (extra task!)
use strict;
my $mailbase = "/home/import_mail";


my $base = "/var/vpopmail/domains";
my $counter;
my $counter;
my $genalias = '';
my $genalias = '';
my $dsync = '';
foreach my $dir ( <$base/*> )
foreach my $dir ( <$base/*> )
{
{
Zeile 61: Zeile 79:


                         }
                         }
                         #print "Insert into mailboxes Values (local_part,password,name,is_domainadmin) ('$values[0]','{CRYPT}$values[1]',
                         #print "Insert into mailboxes Values (local_part,password,name,is_domainadmin) ('$values[0]','{CRYPT}$values[1]','$values[4]',$is_admin)\n";
'$values[4]',$is_admin)\n";
                         print "vboxadm mailbox add $values[0]\@$domain -n '$values[4]' -cp '{CRYPT}$values[1]' --domainadmin $is_admin -a 1 -k 50\n";
                         print "vboxadm mailbox add $values[0]\@$domain -n '$values[4]' -cp '{CRYPT}$values[1]' --domainadmin $is_admin -a
                        #$dsync .= "dsync -o mail_location=maildir:$mailbase/$domain/$values[0]/Maildir -u $values[0]\@$domain backup maildir:~/Maildir\n";
1\n";
                         $is_admin = 0;
                         $is_admin = 0;
                 }
                 }
Zeile 108: Zeile 125:
}
}
print $genalias;
print $genalias;
#print $dsync;
print "/root/courier-dovecot-migrate.pl /home/import_mail/ --recursive --to-dovecot --convert\n";
print "$counter domains\n";</source>
print "$counter domains\n";</source>


[[Kategorie:Mail]]
[[Kategorie:Mail]]
[[Kategorie:Dovecot]]
[[Kategorie:Vpopmail]]
[[Kategorie:Vpopmail]]
[[Kategorie:Perl]]
[[Kategorie:Perl]]

Aktuelle Version vom 9. Juli 2013, 23:06 Uhr

dovecot pop3 config

protocol pop3 {
  pop3_uidl_format = UID%u-%v
}

WARNING: Badly done migration will cause your IMAP and/or POP3 clients to re-download all mails. Read this page carefully: http://wiki2.dovecot.org/Migration


Export User

loop through all domains (e.g. /var/vpopmail/domains)

  • open vpasswd to get real mailboxes with crypted (MD5) passwd
  • look in all mailboxes for a .qmail to get alias
  • look in all .qmail- files to get more aliases


result is a vboxadm-command. vboxadm needs to be patched to import the crypted password. Then call courier-dovecot-migrate.pl to convert Maildirs (to preserv pop3-uids)

vboxadm mailbox add name@domain.de -n 'my name' -cp '{CRYPT}$1$p0cQI5u5$ldfdfdfdfdfma0wLJ.1' --domainadmin 0 -a 1
vboxadm alias add postmaster@domain 'name@domain.de'
/root/courier-dovecot-migrate.pl /home/import_mail/ --recursive --to-dovecot --convert

getuser.pl

#!/usr/bin/perl -w
use strict;

#EDIT
my $base = "/var/vpopmail/domains";

#rsyc /var/vpopmail/domains to newserver /home/admin/import_mail (extra task!)
my $mailbase = "/home/import_mail";

my $counter;
my $genalias = '';
my $dsync = '';
foreach my $dir ( <$base/*> )
{
        next if (! -d "$dir");
        $counter++;
        my $domain = $dir;
        my $allalias ='';
        $domain =~ s/.*\///;
        foreach my $file ( <$dir/vpasswd> )
        {
                next if (!-e $file);

                open(IN,'<'.$file) || die "Can not open file $file: $!";

                while(<IN>){
                        next if ($_=~ /^#/);
                        my @values = split(':',$_);
                        my $is_admin = 0;
                        if ( $values[3] == 4096) {$is_admin = 1;}
                        if ( -e "$dir/$values[0]/.qmail" ){
                                $allalias ='';
                                open(INN,'<'."$dir/$values[0]/.qmail") || die "Can not open file $file: $!";
                                while(<INN>){
                                        next if ($_=~ /^#/);
                                        next if ($_=~ /^\|/);
                                        my $alias = $_;
                                        $alias =~ s/^&//;
                                        chomp($alias);
                                        $allalias = $allalias.";".$alias;
                                }
                                close INN;
                                $allalias =~ s/^;//;
                                if (length($allalias) >0){
                                        #print "vboxadm alias add $values[0]\@$domain '$allalias'\n";
                                        $genalias .= "vboxadm alias add $values[0]\@$domain '$allalias'\n";
                                }

                        }
                        #print "Insert into mailboxes Values (local_part,password,name,is_domainadmin) ('$values[0]','{CRYPT}$values[1]','$values[4]',$is_admin)\n";
                        print "vboxadm mailbox add $values[0]\@$domain -n '$values[4]' -cp '{CRYPT}$values[1]' --domainadmin $is_admin -a 1 -k 50\n";
                        #$dsync .= "dsync -o mail_location=maildir:$mailbase/$domain/$values[0]/Maildir -u $values[0]\@$domain backup maildir:~/Maildir\n";
                        $is_admin = 0;
                }
                close IN;
        }

        #get alias
        foreach my $file ( <$dir/.qmail-*> )
        {
                next if (!-e $file);
                next if ($file =~ /.qmail-default/);
                my $from = $file;
                $from =~ s/.*\///;
                $from =~ s/.qmail-//;
#               print "$file\n";
                $allalias ='';
                open(IN,'<'.$file) || die "Can not open file $file: $!";
                if ( $from =~ /-owner/) {
                        #print "++++++++ML++++++++++\n";
                        #print "Alias $from-help\@$domain \n";
                        #print "Alias $from-subscribe\@$domain \n";
                        #print "Alias $from-unsubscribe\@$domain \n";
                }

                while(<IN>){
                        next if ( !$_ =~ /^&/);
                        if ( $_ =~ /^\|/){
                                next;
                                print "ACHTUNG $_\n";
                        }
                        my $alias = $_;
                        $alias =~ s/^&//;
                        chomp($alias);
                        $allalias = $allalias.";".$alias;
                }
                close IN;
                $allalias =~ s/^;//;
                if (length($allalias) >0){
                        #print "vboxadm alias add $from\@$domain '$allalias'\n";
                        $genalias .= "vboxadm alias add $from\@$domain '$allalias'\n";
                }
        }
}
print $genalias;
#print $dsync;
print "/root/courier-dovecot-migrate.pl /home/import_mail/ --recursive --to-dovecot --convert\n";
print "$counter domains\n";