Migrating from Rackspace Cloud to Cpanel

Fed up with cloud hosting? You’re not alone. Just recently, I assisted a mass exodus of over 50 mysql/joomla based sites. After the migration to just a modest dedicated server with Cpanel, MySQL queries improved by 200% on average. Some longer queries and page loading times saw improvement of over 1000%. Additionally, the dedicated server won’t fall on its face when a single script such as a DB backup process consumes ‘too many’ resources and the Cloud decides to put your whole site in the timeout corner.

Here are some scripts to migrate all your files and db’s from a RackSpace Cloud Sites instance to a Cpanel account quickly and easily. Run this script as the Cpanel user you’re migrating to to avoid ownership issues. If you run this as root, you’ll need to run the ownership repair script in this post.

I was able to pull from 10-20 sites simultaneously and even .htaccess and other ‘hidden’ files came across intact.

The progress will be saved in /home/cpanel_user/xferlog.txt so you can monitor it in realtime. You can launch multiple scripts simultaneously to transfer many sites at once.

#!/bin/sh

RACKSPACE_CLOUD_FTP_USERNAME="rackspace_ftp_user"
RACKSPACE_CLOUD_FTP_PASSWORD="rackspace_ftp_password"
DOMAIN="www.myrackspacedomain.com"

LOCAL_CPANEL_USERNAME=cpanel_username

wget -rc --level=0  --no-parent --cut-dirs=3 -nH \
   --directory-prefix=/home/$LOCAL_CPANEL_USERNAME/public_html/ \
   --user="$RACKSPACE_CLOUD_FTP_USERNAME" \
   --ftp-password="$RACKSPACE_CLOUD_FTP_PASSWORD" \
   ftp://$RACKSPACE_CLOUD_FTP_IP/$DOMAIN/web/content/* \
   -o /home/$LOCAL_CPANEL_USERNAME/xferlog.txt -nv &

Now, let’s migrate a mysql database (this can actually be used for migrating from any host, not just Rackspace). Place the file in the Cpanel user’s home folder so it can be run again right before your DNS switch so your records are totally up to date. You can run it as many times as you wish.

#!/bin/sh
# Rackspace Cloud to Cpanel DB copy

REMOTE_HOST="rackspace_cloud_mysql_ip"
REMOTE_DB="rackspace_cloud_mysql_db"
REMOTE_USER="rackspace_cloud_mysql_user"
REMOTE_PASS="rackspace_cloud_mysql_pass"

LOCAL_HOST="127.0.0.1"
LOCAL_DB="local_cpanel_mysql_db"
LOCAL_USER="local_cpanel_mysql_user"
LOCAL_PASS="local_cpanel_mysql_pass"

MYSQL="$(which mysql)"
MYSQLDUMP="$(which mysqldump)"

CMD="$MYSQLDUMP --lock-tables --add-drop-table \
   -h'$REMOTE_HOST' -u'$REMOTE_USER' -p'$REMOTE_PASS' $REMOTE_DB \
   | $MYSQL -h'$LOCAL_HOST' -u'$LOCAL_USER' -p'$LOCAL_PASS' --database $LOCAL_DB"

echo "Running: $CMD"
echo
eval $CMD

If you’re looking for cheap and reliable Cpanel, Windows, or other types of Managed Hosting, please check out Fast Serv.

$DOMAIN

2 Responses to Migrating from Rackspace Cloud to Cpanel

  1. S. Marachi says:

    Great resource. Thank you for sharing. Would you any advice on moving the Cloudsites email users and emails?

  2. Seb says:

    Hi Randy,

    Do you know if this still works with the current Rackspace Cloud environment. Tried your code exactly and nothing. Anything special on the dedi side that I need to have running/active to allow the pull? Any help is appreciated. Hate to manually move sites.