DTC-Xen Installation

DTC-Xen / Dom0 Howtos

DTC-Xen / DomU Howtos


DTC Howtos




Devel docs

Wiki - i18n

Wiki - Meta


This guide is to help those migrating to a new server.

It is designed to help you migrate your DTC with minimal or NO downtime to your webserver and applications. It expects that you're already fairly proficient and comfortable with the command line and your OS in general. Definitely not for beginners, hire a professional.

Note that there's now a migration script called "dtc_migrate" that will do most of the work in one command line.

Using dtc_migrate script:

Before you start the script:

On the new machine:

  • Install dtc,
  • Make sure to run the dtc install script once (This solves an issue when importing the 'mysql' database to new server).
  • Install rsync
 aptitude install rsync
  • If you have dtc-dos-firewall running you'll need to temporarily disable it:
 /etc/init.d/dtc-dos-firewall stop

On the old machine:

  • Create a ssh key pair without passphrase,
  • Copy-paste the pub key to /root/.ssh/authorized_keys on the new machine

Let's start the script:
On the machine that is currently running dtc run (changing <new_ip> with the new server's ip):

 cd /usr/share/dtc/admin/
 ./dtc_migrate <new_ip>

If the current server and the new server have different architectures (for example if the current server has i386 architecture and the new server has amd64 architecture), you have to convert the rrd files to xml and then restore them in the new server converting them to the new architecture. To do it, in the machine that is currently running dtc run (changing <new_ip> with the new server's ip):

 rrdtool dump /var/lib/mailgraph/mailgraph_virus.rrd > 1.xml
 rrdtool dump /var/lib/mailgraph/mailgraph.rrd > 2.xml
 rrdtool dump /var/lib/dtc/etc/cpu.rrd > 3.xml
 rrdtool dump /var/lib/dtc/etc/netusage.rrd > 4.xml
 rrdtool dump /var/lib/dtc/etc/stat_total_active_prods.rrd > 5.xml
 rrdtool dump /var/lib/dtc/etc/memusage.rrd > 6.xml
 rrdtool dump /var/lib/dtc/etc/mailqueues.rrd > 7.xml
 scp *.xml <new_ip>:/root

Then in the new server run:

 mv /var/lib/mailgraph/mailgraph_virus.rrd /root/
 mv /var/lib/mailgraph/mailgraph.rrd /root/
 mv /var/lib/dtc/etc/cpu.rrd /root/
 mv /var/lib/dtc/etc/netusage.rrd /root/
 mv /var/lib/dtc/etc/stat_total_active_prods.rrd /root/
 mv /var/lib/dtc/etc/memusage.rrd /root/
 mv /var/lib/dtc/etc/mailqueues.rrd /root/

 rrdtool restore 1.xml /var/lib/mailgraph/mailgraph_virus.rrd
 rrdtool restore 2.xml /var/lib/mailgraph/mailgraph.rrd
 rrdtool restore 3.xml /var/lib/dtc/etc/cpu.rrd
 rrdtool restore 4.xml /var/lib/dtc/etc/netusage.rrd
 rrdtool restore 5.xml /var/lib/dtc/etc/stat_total_active_prods.rrd
 rrdtool restore 6.xml /var/lib/dtc/etc/memusage.rrd
 rrdtool restore 7.xml /var/lib/dtc/etc/mailqueues.rrd

 chown dtc:root /var/lib/mailgraph/*.rrd
 chown dtc:dtcgrp /var/lib/dtc/etc/*.rrd

The old method:

IMPORTANT: This is a deprecated method, and it is not endorsed by GPL Host. We would advise you not to use it or use it at your own risks

1. First install dtc as directed.
Your control panel will not be visible in your old domain yet because you haven't pointed your dns yet, however you still need to test to see it DTC installed and is working correctly. So you do one of two things: alter your hosts file with a line that reads "<new-server-ip> <your dtc panel domain name>" or use the direct IP method of https://<new-server-ip>/dtcadmin(approve sites) . Once you confirm that you have no errors in your configuration generation page and all is working properly, you can proceed.

2. Put all your webapps into maintenance mode
(i.e., Moodle, Joomla) so that no changes can be made(which won't reflect after you point your DNS to the new server).

3. Migrate your files
On your old server:
tar -czvf ~/files.tgz /var/www/sites
On your new server:
tar -xzvf ~/files.tgz /var/www
chown -R dtc:dtcgrp /var/www/sites (the install script should do this, but just in case) \\
4. Migrate your cron jobs
On your old server:
crontab -l (highlight and cut)
On your new server:
crontab -e (paste and save)

5. Backup your Databases
On your old system: (if someone knows an easier way of doing this please share)
mkdir ~/databases
For each database your will do a:
mysqldump -p <database name> > ~/databases/<database name>
Do not forget the MYSQL and INFORMATION_SCHEMA databases.

6. Transfer your databases
On the new server:
mkdir ~/databases
On the old server
scp ~/databases/* root@<new server ip>:/root/databases

7. Load up your databases
On the new server:
For each database you will perform the following:
mysql -p
create <database name>;
mysql -p <database name> < ~/databases/<database name>
* Remember that once you do this the mysql will revert to the password on the old server

  • Also, take care that the password of the Debian user that is there for maintenance matches what you have in /etc/mysql/debian.cnf (you can change the value of the password in this file taking what's stored in the old server, or see below).

An option that works for copying the database to another server is to shutdown MySQL using:
/etc/init.d/mysql stop
then do
tar -czvf database.tgz /var/lib/mysql
now copy the file to the root directory of the new server using
scp database.tgz root@<newserver ip>:/
now stop MySQL on the new server
/etc/init.d/mysql stop
and extract the tarball
tar -xzvf database.tgz
restart MySQL
/etc/init.d/mysql start
It will error, but now do step 8 and all should be fine

8. Sync the passwords on the database
On the new server:
Locate the password in /etc/mysql/debian.cnf
mysql -p
UPDATE mysql.user SET Password=PASSWORD('<new password>') WHERE User='debian-sys-maint';
run the installation script again

9. Point your DNS to the new server
10. As your new servers DNS begins to replicate start taking your webapps out of maintenance mode. If you can't wait around for that to happen, put them in the /etc/hosts file to point them to the new server so that you can take them out of maintenance mode.
Your done!!!

Courtesy of Francisco Barcenas(fbc<at>

Editing this page means accepting its license.

Page last modified on May 11, 2013, at 09:49 PM EST