How I migrated a WordPresss site from Openshift to LAMP
Migrate WP from OpenShift

How I migrated a WordPresss site from Openshift to LAMP

One of my clients recently had a requirement to migrate his WordPress site hosted in openshift to a normal server. I offered him a free migration thinking that it could be fairly straightforward, but as I started I realized it is not going to be easy as I thought.

WP in openshift is highly customised, and for that reason, I had a tough time getting the lines straight and start the process. So I logged into the WP and disabled all the plugins to start with.

Step 1 – Install WP

The first and foremost step when doing such migration is to install a new WordPress site on the target server. Since the new server was a cPanel one, I set it up WP from the softaculous area.

Step 2 – Establish SSH connection to Openshift APP.

Login to openshift account, and then navigate to settings area and then add your public ssh key in the described format.

Step 3 – Test SSH

Once the ssh key has been added, navigate to the application. On the right side you should be able to see the ssh command to enter to the application. For me it was:

ssh [email protected]

Once I logged in there, the next step was to find where the document root of the WordPress installation was.

It was at app-root/data/current/ , and I navigated to that location.

cd app-root/data/current/

Step 4 – Download Data

The wp-content folder normally contain the pluginx , themes and the uploads folder. But in openshift wordpress application, these folders are synlinked to /app-root/data/plugins , /app-root/data/themes /app-root/data/uploads.

So use this command from your computer to sync those folders from the openshift.

mkdir wp-content ; cd wp-content 
rsync -avz -e "ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" --progress [email protected]:/var/lib/openshift/5638d2f67628e1dxxxxx/app-root/data/uploads  ./
rsync -avz -e "ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" --progress [email protected]:/var/lib/openshift/5638d2f67628e1dxxxxx/app-root/data/themes ./
rsync -avz -e "ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" --progress [email protected]:/var/lib/openshift/5638d2f67628e1dxxxxx/app-root/data/plugins ./

Step 5 – Download database

SSH to the server, and run the following commands, and replace dbname with the dbname taken from the applications page.

ssh [email protected]
mkdir -p app-root/data/tmp/
mysqldump -h $OPENSHIFT_MYSQL_DB_HOST -P ${OPENSHIFT_MYSQL_DB_PORT:-3306} -u ${OPENSHIFT_MYSQL_DB_USERNAME:-'admin'} --password="$OPENSHIFT_MYSQL_DB_PASSWORD" --dbname > ~/app-root/data/tmp/dbname.sql

Now go back to your computer and run this rsync command to download the db copy.

rsync -avz -e "ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" --progress [email protected]:/var/lib/openshift/5638d2f67628e1dxxxxx/app-root/data/tmp ./

Now use phpmyadmin to populate the DB to the DB in the new WP that you have created on the new server. Then upload the wp-content folder that we created in step 4 so that it will contain the themes, uploads and plugins folders.


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Close Menu