View Single Post
  #185  
Old 20th September 2010, 14:45
gauthier gauthier is offline
Member
 
Join Date: Oct 2007
Posts: 58
Thanks: 5
Thanked 3 Times in 2 Posts
Default

Hi,

Yesterday I migrate to a new server using information I get in this post. All is running fine now, so this is another success story.

I am not an expert at all, but I would like to share this little "how to" have made using contributions I have read here and on others places. I have no doubt the migration can be done better but at least this way worked fine for me.

I have ISPconfig 2.2.37 running on debian 5.

I did not created the Postfix transport to forward emails to the new server (should be added to this howto).

Of course I am not sure there is no error, you do this howto at your own risk.

If you see something have to be added or corrected, please let us know.

I hope this will help some of you.


Quote:
// OLD SERVER

//if not done, update ispconfig2 to the latest version
// I assume you have created the cpdb.bash file and make it runnable by: "chmod a+x cpdb.bash" the containing of the cpdb.bash file is at the end of this text.

// create your backups folder if you do not already have one:
cd /root
mkdir backups

// create a "today" directory
today=`date +%d-%m-%y`
cd /root/backups
mkdir $today
cd $today

// I will create 3 compressed files that are "data.tar.gz", "www.tar.gz" and "tarsql"

mkdir data

/etc/init.d/postfix stop

//if one of the following lines fails, use "locate" to find where are the needed files on your server:
//example: locate pri.*
//before using locate, it is good to run updatedb
//if locate is not installed on your server, run "apt-get install locate" and then run "updatedb"

cp /etc/passwd /root/backups/$today/data
cp /etc/shadow /root/backups/$today/data
cp /etc/group /root/backups/$today/data
cp /etc/apache2/vhosts/Vhosts_ispconfig.conf /root/backups/$today/data
cp /etc/postfix/local-host-names /root/backups/$today/data
cp /etc/postfix/virtusertable /root/backups/$today/data
cp /var/lib/named/etc/bind/named.conf /root/backups/$today/data
cp /etc/proftpd*.conf /root/backups/$today/data
cp /var/lib/named/etc/bind/pri.* /root/backups/$today/data

/etc/init.d/postfix start

// emails received from now will not be included in the backup.

tar -pczf data.tar.gz data/
rm -r data


./cpdb.bash
tar -pczf tarsql *.sql
rm *.sql

// changes in your databases from now will not be included in the backup

tar -pczf www.tar.gz /var/www/
// (or replace by the folder containing your webs)


// NEW SERVER

//Do the corresponding perfect setup as shown at "http://www.ispconfig.org/ispconfig-2/installation-instructions-for-ispconfig-2/"

// if you are using the remote framework (like me) do not forget:
apt-get install libxml2-dev

// I am supposing you only have remote access to your server, for in case your PC looses conexion to internet I would suggest this:
apt-get install screen
screen
//If you loose access to your server, you can reload the current shell using: "screen -rd"


// INSTALL ISPCONFIG
cd /root
mkdir ispconfig_temp
cd ispconfig_temp
wget -c http://sourceforge.net/projects/ispc...ar.gz/download
// (replace with the current link for last ispconfig version dowload)

tar xvfz ISPConfig-2.x.xx.tar.gz
cd install_ispconfig

//If you use remote framework:
vi compile_aps/compile
add the folowing line:
WITH_XML=""
just after the WITH_XML variable is beeing set, so that php will compile with XML in all cases.

//if you have already ran the ispconfig instalation and it failed, run:
mkdir /root/ispconfig

./setup

//check you have access to the control panel : "https://yourip:81"

cd /root
mkdir backups
cd backups
today=`date +%d-%m-%y`
mkdir $today
cd $today
apt-get install sftp
sftp ip_old_server
root
your_root_pass_on_old_server
get /root/backups/19-09-10/data.tar.gz (replace the date)
get /root/backups/19-09-10/www.tar.gz
get /root/backups/19-09-10/tarsql
exit


// MYSQL
mkdir db
mv tarsql db/
cd db
tar xvfz tarsql
rm tarsql
// this will make a good job I think:
perl -pi -e 's/old_ip/new_ip/g' db_ispconfig.sql
perl -pi -e 's/old_host/new_host/g' db_ispconfig.sql
perl -pi -e 's/old_domain/new_domain/g' db_ispconfig.sql

// if (like me) you have undreeds of databases, you can:
ls > list.txt
// download list.txt with filezilla on your pc and using a advanced text editor, you replace the "new line" character and make the file look like:
#!/bin/bash
#recovering dbs
mysql < database_1.sql -h localhost -u root -pyour_mysql_root_pass
mysql < database_2.sql -h localhost -u root -pyour_mysql_root_pass
mysql < database_3.sql -h localhost -u root -pyour_mysql_root_pass
mysql < database_4.sql -h localhost -u root -pyour_mysql_root_pass
mysql < database_5.sql -h localhost -u root -pyour_mysql_root_pass
.....
// relaod the list.txt
chmod a+x list.txt
./list.txt

// WWW
// (supposing your web files are in the /var/www/ file)
mv www.tar.gz /var/
cd /var
mv www www_delete_me_if_all_ok
tar xvfz www.tar.gz

// DATA
cd /root/backups/18-09-10
tar xvfz data.tar.gz

// have a look at passwd, shadow, group files and if necesary update them with files from old server changing ip, host and domain.
// use the perl command:
perl -pi -e 's/old_string/new_string/' file

// you will have to do it at least with the pri.*, proftpd* and Vhosts_ispconfig.conf files:

perl -pi -e 's/old_ip/new_ip/g' pri.*

perl -pi -e 's/old_ip/new_ip/g' proftpd*
perl -pi -e 's/old_host/new_host/g' proftpd*
perl -pi -e 's/old_domain/new_domain/g' proftpd*

perl -pi -e 's/old_ip/new_ip/g' Vhosts_ispconfig.conf
perl -pi -e 's/old_host/new_host/g' Vhosts_ispconfig.conf
perl -pi -e 's/old_domain/new_domain/g' Vhosts_ispconfig.conf

cd /var/lib/named/etc/bind/
mkdir bind_delete_me_if_all_ok
cp * bind_delete_me_if_all_ok/
cp /root/backups/18-09-10/data/pri.* /var/lib/named/etc/bind/

cd /etc

mkdir proftpd_delete_me_if_all_ok
mv proftpd.conf proftpd_delete_me_if_all_ok/
mv proftpd_ispconfig.conf proftpd_delete_me_if_all_ok/
cp /root/backups/18-09-10/data/etc/proftpd.conf /etc/
cp /root/backups/18-09-10/data/etc/proftpd_ispconfig.conf /etc/


//check files in /etc/apache2/vhosts and /etc/postfix and replace them if necesary

/etc/init.d/proftpd restart
/etc/init.d/apache2 restart


https://yourip:81
enable Maildir under Management -> Server -> Settings -> EMail in the ISPConfig web interface

Change nameserver ns1 and ns2 to the new server ip.

If all ok, "locate delete_me_if_all_ok" and remove.




///// CONTAINING OF cpdb.bash FILE ////////
CMD_MYSQL="/usr/bin/mysql"
CMD_MYSQLDUMP="/usr/bin/mysqldump"
# login credentials of the submitting side
DB_USER_FROM="root"
DB_PASS_FROM="your_root_pass_for_mysql"
DB_HOST_FROM="localhost"
# index all databases on the local (submitting) side
echo "database sync"
DATABASES=`echo "SHOW DATABASES;" | ${CMD_MYSQL} -p${DB_PASS_FROM} -u ${DB_USER_FROM} -h ${DB_HOST_FROM}`
for DATABASE in $DATABASES; do
# skip non-databases
if [ "${DATABASE}" != "Database" ] && [ "${DATABASE}" != "information_schema" ]; then
${CMD_MYSQLDUMP} -Q -B --create-options --delayed-insert --complete-insert --quote-names --add-drop-table -p${DB_PASS_FROM} -u${DB_USER_FROM} -h${DB_HOST_FROM} ${DATABASE} > ${DATABASE}.sql
fi
done
Reply With Quote