Home > FreeBSD General > Move a Server

Move a Server

March 8, 2009 Posted by KP

In the last 6 months, I have rebuilt my server four times due to ISP change or hard disk problems. Minimal down time and data consistency are two most factors when move to a new server. Here’s how I usually move a server:

Step 1. Build the new server
Install and configure all required programs, such as Bind, Apache, PHP, MySQL, Postfix.

I use one user account for each website. adduser command has ‘-f’ option for batch adding users.

Create all databases and user accounts, this can be done with a MySQL script (reusable as well).

There is no harry to do this step as the transfer hasn’t started yet.

Step 2. Backup data on old server
I always directly tar MySQL data directory. I will stop Apache and MySQL for 10 minutes, it is acceptable to me.

Step 3. Copy data to the new server
100MB port is very helpful at this moment :-).

Step 4. Restore the data on the new server
Extract the big file and move the data to corresponding directories. I have created a script before step 2. This step only took a few minutes. The script looks like:

#!/bin/sh
mv /backup/transfer/account1/www/ /home/account1/
mv /backup/transfer/account2/www/ /home/account2/

mv /backup/transfer/db/mysql/database1/* /var/db/mysql/database2/
mv /backup/transfer/db/mysql/database2/* /var/db/mysql/database2/

This is the best way I can think of to restore the data, all file attributes will be retained, only a couple of commands to do the job.

Step 5. Now the transfer is finished.
Start applications on the new server, it’s now ready to accept connections. Modify domain records if needed.

Some websites may not work immediately, but usually they are simple errors such as PHP.ini configuration or wrong DB password. The is my favorite part, some simple checks here and there to make them work magically. :-)

Step 6. Modify the DNS zone files (www IP) on the old server.
Bind on old server will still get lots of queries for a few hours, but it will redirect the visits to the new server.

Summary
The time that step 2 takes is the down time, less than 20 minutes.

Step 3 and 4 may take from 10 minutes up to an hour, this time may cause inconsistent data, especially when there are active forums.

Every time I move to a new server, I always have to deal with one or two email service providers. So far, I have contacted bellsouth.net, comcast, hotmail, etc. This time, it’s AOL, they haven’t unblocked my new IP after three days. I hate this part, there is nothing I can do except for sending them polite emails.

Bookmark and Share


Related Posts:

Filed Under: FreeBSD General

Leave a Comment









*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word




Categories

Archives

Links

  • Dedicated Servers
  • Meta