@@ -0,0 +1,87 @@
#! /bin/bash
# Migrate ISPConfig 3 installation from one server to another
# This script should run on the final/destination ISPConfig 3 server
# You must first install the same ISPConfig on the destination server
# and make sure to create all the users from the previous installation
# (ISPConfig creates users for each client and web page)
# Tested on ISPConfig version 3.0.5.3
# Created by Jorge Barnaby (@jbarnaby) - March 2014
# EDIT YOUR PREVIOUS ISPCONFIG SERVER HERE
main_server=old-server.domain.com
# common_args='-aPv --delete'
# common_args='-aPv --dry-run'
common_args=' -aPv'
www_start=" service apache2 start"
www_stop=" service apache2 stop"
db_start=" service mysql start"
db_stop=" service mysql stop"
function db_migration {
echo " ---- Starting DB migration..."
# Stop Remote and Local MySQL Servers
ssh $main_server " $db_stop "
$db_stop
# Copy MySQL files
rsync $common_args --compress --delete $main_server :/var/lib/mysql/ /var/lib/mysql
# Start Remote and Local MySQL Servers
ssh $main_server " $db_start "
$db_start
# TODO:
# You should update ISPConfig MySQL Password to match your new server's, as it's stored in
# several ISPConfig files (it's a faster approach than updating the password in all those places)
# Enter MySQL on the destination server and run:
# SET PASSWORD FOR 'ispconfig'@'localhost' = PASSWORD('YOUR NEW ISPCONFIG MYSQL PASSWORD');
# You should also make shure all the tables on the destination server are clean:
# mysqlcheck -A --auto-repair
echo " ---- DB migration done."
}
function www_migration {
echo " ---- Starting WWW migration..."
$www_stop
rsync $common_args --compress --delete $main_server :/var/www/ /var/www
rsync $common_args --compress --delete $main_server :/var/log/ispconfig/httpd/ /var/log/ispconfig/httpd
$www_start
echo " ---- WWW migration done."
}
function mail_migration {
echo " ---- Starting Mail migration..."
rsync $common_args --compress --delete $main_server :/var/vmail/ /var/vmail
rsync $common_args --compress --delete $main_server :/var/log/mail.* /var/log/
echo " ---- Mail migration done."
}
function files_migration {
echo " ---- Starting Files migration..."
rsync $common_args $main_server :/var/backup/ /var/backup
# The following files are copied just to have a reference of the previous
# installation users and groups. You should manually create those users in
# your new server
rsync $common_args $main_server :/etc/passwd /root/old-server/
rsync $common_args $main_server :/etc/group /root/old-server/
echo " ---- Files migration done."
}
function mailman_migration {
echo " Starting MailMan Migration..."
rsync $common_args --compress --delete $main_server :/var/lib/mailman/lists /var/lib/mailman
rsync $common_args --compress --delete $main_server :/var/lib/mailman/data /var/lib/mailman
rsync $common_args --compress --delete $main_server :/var/lib/mailman/archives /var/lib/mailman
# Update / Regenerate aliases
cd /var/lib/mailman/bin && ./genaliases
echo " MailMan Migration done."
}
# Execute migrations
www_migration
mail_migration
db_migration
files_migration
mailman_migration