wiki:transfer_site_between_servers

Version 3 (modified by Jamie McClelland, 16 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 (below is a sample transcript)
    0 harry:/usr/local/share/red/scripts$ ./transfer-red-items-to-new-host 
    Please enter the domain name of the hosting order to move? ibew25.org
    Hosting Order ID: 541
    Member: IBEW Local 25
    Current host: malcolm.mayfirst.org
    Please enter the full domain name of the new host. jones.mayfirst.org
    Cranking down time to live for DNS to 300 seconds
    Pseudo-terminal will not be allocated because stdin is not a terminal.
    DNS record updated for ibew25.org
    Pseudo-terminal will not be allocated because stdin is not a terminal.
    DNS record updated for www.ibew25.org
    Pseudo-terminal will not be allocated because stdin is not a terminal.
    DNS record updated for mail.ibew25.org
    Pseudo-terminal will not be allocated because stdin is not a terminal.
    DNS record updated for ibew25.mayfirst.org
    Pseudo-terminal will not be allocated because stdin is not a terminal.
    DNS record updated for ibew25.org
    Pseudo-terminal will not be allocated because stdin is not a terminal.
    DNS record updated for advantage.ibew25.org
    Creating new hosting order
    New hosting order created (700)
    Moving red_items to newly created hosting order and setting as transfer-limbo
    Done
    Updating hosting order with new host (jones.mayfirst.org)
    Making duplicate red_items on new host
    Working on item: 11206
    Pseudo-terminal will not be allocated because stdin is not a terminal.
    Committed: 14596
    Working on item: 11207
    Pseudo-terminal will not be allocated because stdin is not a terminal.
    Committed: 14597
    Working on item: 11208
    Pseudo-terminal will not be allocated because stdin is not a terminal.
    Committed: 14598
    Working on item: 11291
    Pseudo-terminal will not be allocated because stdin is not a terminal.
    Committed: 14599
    0 harry:/usr/local/share/red/scripts$
    

This script will ask you for the domain name of the hosting order you want to transfer and the name of the new 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 new 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