Migration script: moving a DTC instance to another server

1. Purpose

You moved provider, and you wish to have all of your setup to be moved to the new one, or you simply have a new system. Migrating all by hand is a long, boring process, where you have to first migrate all files from /var/www/sites, then all DBs, and doing some tweaks in the mysql and dtc db on the fly before importing. It's not only boring, it's also very error prone. To solve this, DTC comes with a migration script.

2. Get the scripts

Currently, the migration script is only available in the Git version (master branch) of DTC, it's not yet in the release version. But the good news is that it works everywhere, including in the old version. The only thing you have to do is get the 4 files needed for the migration and you are done. To get these files, just go here:

http://git.gplhost.com/gitweb/?p=dtc.git;a=summary

Click on the topmost (so you get the latest version) "tree" link, which will show the tree of files in the Git repository. Then click on "admin" on the left. Then you got to get 4 files:

   dtc_migrate
   guess_ip.sh
   migrate_to_server.php
   dtc_import_all_dbs

To get them, best is to right click on the "raw" link on the right, then do a "save as". Once you got the 4 files, drop them in the "dtc/admin" folder of your old server.

3. Prepare the new server

Nothing much to say here. Just get DTC installed in the new server the normal way. Then, you should maybe disable the ssh DOS firewall for incoming connections from the old server, because it might connect to a rate which is too fast for the DTC anti-DoS firewall. If you are too lazy to add new iptables rules, just do:

   /etc/init.d/dtc-dos-firewall stop

otherwise, just whitelist your old server with something like this (recommended):

   iptables -I INPUT -s 1.2.3.4 -j ACCEPT

of course, replace 1.2.3.4 with the IP of your old server.

4. Setup ssh keys

Before anything, best is to setup ssh keys, so that you old server can connect to the new one without a password. Simply create a new ssh public/private keypair on the old server with:

   ssh-keygen -t rsa

then press ENTER to use a blank password. Then copy the content of /root/.ssh/id_rsa.pub into the new server under /root/.ssh/authorized_keys2 (the final 2 is valid only with Debian servers, otherwise you don't want it).

5. Starting the migration script

Go in the old server and do:

   cd /usr/share/dtc/admin
   dtc_migrate -d 1.2.3.5

1.2.3.5 is the IP address of your new server. It could also well be a valid hostname that the old server can resolve. The -d parameter is an optional parameter that will delete all DBs on the new server before importing them.

Watch it running, then when it's finished ... that's it you are done! The only remaining thing to do is have your DNS point to the new server! :)


Editing this page means accepting its license.

Page last modified on August 28, 2010, at 05:31 AM EST