wiki:transfer_site_between_servers

Version 1 (modified by Jamie McClelland, 12 years ago) (diff)

--

How do I move a hosting order from one server to another server?

This help page is intended for May First/People Link administrators. Root access to the servers in question is required.

To help distribute load evenly between our standard servers, it is sometimes necessary to move a hosting order from one server to another. These steps document a process for making a move that allows you to copy and test the move before making a final commitment.

Create the appropriate items in the Members Control panel

The first step is to run the transfer-red-items-to-new-host script from harry.mayfirst.org:

  • Login as root:
    ssh root@harry.mayfirst.org
    
  • Become the www-data user (which has the ability to notify hosts of item changes)
    su www-data
    
  • Execute the script (FIXME: add sample transcript)
    /usr/local/share/red/scripts/transfer-red-items-to-new-host
    

This script will ask you for the domain name of the hosting order you want to transfer and the name of the host you want to transfer it to.

It does a number of steps for you:

  • Cranks down the time to live for the DNS records to 300 seconds
  • Creates a new hosting order in the state "transfer-limbo" with the same values as the existing hosting order.
  • Re-assigns all existing red items to the new transfer-limbo hosting order. These items remain unchanged on the current host (in other words, user accounts, web sites, etc. continue working on the current host). However, they cannot be modified since they are in transfer-limbo.
  • Updates the existing hosting order with the new host.
  • Creates a copy of every red item, attaching them to the existing hosting order (and assigning them to the new host).

When you are done, there will be two hosting orders - one that is in transfer-limbo (and is currently active) and one that is installed on the new target host.

Copy data from the current to the new host

Next, copy the data from the current host to the new host by logging into the current host as root (with authentication credentials being forwarded):

ssh -A root@current.host.org

Then, run the copy-data-to-new-host script, passing the target host as the first argument and the path to the hosting order as the second. For example:

/usr/local/share/red/scripts/copy-data-to-new-host new.host.org /home/members/mayfirst/sites/mayfirst.org

This script will rsync all the data, preserving permissions and ownership, to the new host. Then, it will search for a Drupal database and if it finds one, create it (and the associated username) to the new host and then dump the data. Finally, it will search for crontabs on the current host, re-creating any it finds on the new host.

You can safely run this script as many times as you like.

Note: the script does not detect databases other than those used by Drupal. If the hosting order is using a non-Drupal database you will need to transfer it by hand.

Test

The next step is to test. You can test by modifying your hosts file so that the domain name used by the site your are moving resolves to the IP address of the new host.

Switch

If all goes well with the test, you can finalize the move by modifying the DNS records to point the domain name(s) to the IP of the new host. While you are changing the IP records, be sure to change the time to live back to a reasonable number.

Clean up

Once the transfer has happened, and the site is confirmed to be working and completely intact, you will need to remove the transfer-limbo hosting order:

  • From seso, search for the hosting order and click delete. This process will remove all associated red items
  • Login to the old host and:
    • manually remove any databases associated with the hosting order
    • manually remove any crontabs
    • remove the hosting order directory