Mail-Toaster
view release on metacpan or search on metacpan
bin/toaster_migrate.pl view on Meta::CPAN
print "checking smtproutes for $domain...";
my $r = `grep $domain /var/qmail/control/smtproutes`;
$r ? print "ok.\n" : print "FAILED.\n";
unless ($r) {
if ($util->yes_or_no( "shall I do that for you?", force=>1) ){
$util->file_write("/var/qmail/control/smtproutes", lines=>["$domain:$host"], append=>1);
};
};
};
sub rsync_mailboxes_to_new
{
my ($domain, $host) = @_;
if ($exists) {
print "executing commands on $host\n";
my $cleanup = "rm -r $vpopdir/domains/$domain";
my $clean2 = "mv $vpopdir/domains/$domain.bak $vpopdir/domains/$domain";
print " $cleanup\n";
$util->syscmd("ssh $host $cleanup", verbose=>0);
print " $clean2\n";
$util->syscmd("ssh $host $clean2", verbose=>0);
};
my $cmd = "rsync -av -e ssh --delete $vpopdir/domains/$domain $host:$vpopdir/domains/";
print "rsync the maildirs from this (old) server to the new one with:\n\n $cmd \n\n";
if ( $util->yes_or_no( "\nshall I try it for you?", force=>1) ) {
$util->syscmd($cmd, verbose=>0);
};
unless ( $util->yes_or_no( "\nhas the previous task completed successfully?", force=>1) ) {
die "ok, bombing out!\n";
};
};
sub _usage {
my ($dom, $host) = @_;
print "
This script must be run on the OLD server and it will copy files to new server. You'll need two things set up.
1. rsync installed on both systems
2. SSH key based authentication for root from old to new
The former you can figure out yourself. The latter is a little harder, but not terribly difficult. First, you need to have SSH as root enabled on the new server. Do NOT allow root authentication with passwords. Accomplish this by setting PermitRootLo...
usage: $0 user username newhost.fqdn.com (user = /etc/passwd username)
$0 domain example.com newhost.fqdn.com (domain = vpopmail domain name)
";
die "\n" unless ($dom and $host);
}
sub _check_my_cnf
{
my ($homedir) = (getpwuid ($<))[7];
unless ( $util->is_readable( "$homedir/.my.cnf" ) )
{
print "\nHey bubba, I need to connect to your MySQL server as the root or vpopmail user. To facilitate this, I expect a configured ~/.my.cnf file. This file format is the same as the mysql client uses and properly configured might look like this:
[mysql]
user = vpopmail
pass = superSecretReallySecurePasswordBecauseImSmart
Create that file now, make sure it's readable by the user only (chmod 0400 ~/.my.cnf), and then rerun this script.
";
die "\n";
};
}
exit 0;
=head1 DEPENDENCIES
Mail Toaster
=head1 BUGS AND LIMITATIONS
Needs more and better documentation, and explanations of what it is doing
Needs to migrate valias entries from MySQL
Please report any bugs or feature requests to
C<bug-mail-toaster@rt.cpan.org>, or through the web interface at
L<http://rt.cpan.org>.
=head1 AUTHOR
Matt Simerson C<< <matt@tnpi.net> >>
( run in 2.103 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )