This article is an answer to a question I got recently, which stated:

When you transfer your site from old domain or localhost to new domain, what are the steps to take and what errors do you need to look for?

Servers In Data Center

While this question is about transferring a domain it also applies to changing hosts. Coincidentally, I did that very thing this week. So to do this we are going to need to do 3 things:

  1. Backup the Files.
  2. Backup the Database.
  3. Point the domain to the proper IP address.
  4. Import the Files.
  5. Import the Database.

A quick note before I explain the procedures. The order of these things matters, not so much on the backup but on the import it can matter a bunch as you will see below.

Backup Files

The files in WordPress are of 2 types, there is WordPress core files which drives the WordPress system. We are not interested in those.  Core files are located in the root of the install. The user files are stored in a directory called wp-content.

Depending upon the setup you have you may see a variety of directories within this one. However, there are 3 directories that we are interested in:

  • Themes stores your theme files.
  • Plugins stores your plugin files.
  • Uploads stores your media files and documents.

I recommend that you make a copy of wp-content so you have everything you need. If you are on a local install, called localhost or 127.0.0.1 (localhost IP address) you already have these on your system. Just navigate to the folder that contains you WordPress installation.

If you are on a host and you are moving to another one, use your FTP client to navigate to the wp-content folder and download everything to your computer. Once you have done this  you can more on to the next step, backup the database.

Backup Database

Backing up the database on WordPress is interesting because there are 2 ways to do this. One is far easier for the average user but it isn’t quite is thorough. The second is more thorough but it is harder and requires more technical knowledge. I am going to show you both methods and you pick which one you want to use.

Easy Way

The easy way uses functionality built into WordPress. This is the recommended way for most users. To access this functionality on the WordPress Dashboard -> Tools -> Export. The system will then ask you what to export and you want to click all content (this should be selected by default). This will download an xml file with all your content. Check your downloads folder and you will see it.

Hard (More Thorough) Way

If you want to do it the harder but more thorough way, then you will backup the entire database. The step we just did above only gave us the content, which is themes, plugins, posts, pages and media files. The database stores more than the content. It still stores all the content but it gives us the full system settings as well.

To backup the database go find PHPMyAdmin in your local server or your host’s cPanel. Once in there select the database you want and click the export button. In the dialog that appears select quick under export method and the dropdown should be SQL. Click Go and the file will download. You have just exported the full database.

PHPMyAdmin Export

Point the Domain To Your Host

Now you need to go point to the domain to your hosting provider via DNS. The DNS translates human readable domains like google.com to an IP address like 1.2.3.4. You are going to need to create an A record with your registrar.

Please note it is very common for your host to also be the registrar but this is not always the case. If your registrar and your host are different companies you need to login to your account with your registrar to point them to the host. However, you will need to first get the IP address from your host.

Once you have your host’s IP address login to your register and go to the DNS section for the domain you want to point. You are going to add 2 A records with the following values:

TypeHostValueTTL
A@IP AddressTime
A*IP AddressTime

Depending upon your registrar’s system the TTL (Time to Live) value may be in minutes or seconds. Just select the shortest option.

Import The Files

Remember earlier I said the order mattered, well now I will explain. I want to you move the files first because the media library will not find the files (and thus will not add them) if you import the data before the files. So I recommend moving the files first. Please note you will need a WordPress install (or at least the file structure) up and running before you can move the files, which I discuss here.

Once the WordPress install is created and your FTP is setup with your host navigate into the wp-content directory both locally and on your host. Move the Themes, Plugins, and Uploads directories from you computer to the host.

Import The Database

Just like above there is an easy way, good for most users, and the harder more thorough way.  I will explain each method.

Easy Way

The easy way will use a feature of WordPress called the WordPress Importer. On the WordPress Dashboard go to Tools->Import. There you will see a bunch of options. At the end of the list is the WordPress importer. Click install and then run the tool. When you run it will ask for the export xml file we dowloaded earlier. This should import all the system data. When you import you may need to reassign content to a user.

Hard (More Thorough) Way

Before you import the database you need to get a fresh install. Using this method you will need to do it manually. Go to WordPress.org and download the files. Extracted the files from the zip and FTP them to your root directory on your host. Now you can move the database.

On your hosts cPanel go to the databases section. Create the exact same name as the database from your localhost or other host. Then go to your new host’s PHPMyAdmin and find the database you created and select it. It should not have tables. Click the import button and import your SQL file. Then install WordPress manually using that database as the database and the same table prefix as the prefix used in the database you are moving.

Troubleshooting

Moving a WordPress website doesn’t always go smoothly. Below is a list of the most common issues I have run into and how to solve them:

  • Issues with the domain: DNS can take up to 72 hour to take effect across the internet. This is why we set the TTL to the lowest value possible. You may need to be patient. Also confirm that your records are pointing to the correct IP address that you got from your host.
  • Cannot install WordPress: This is more common in manual installations. Ensure that your database name is correct and that all the usernames and passwords match. Also ensure that your table prefixes match the previous version as well. If necessary delete all WordPress files get a fresh download and start over.
  • Settings are not correct: This happens when you use the WordPress Importer since it only affects content, not settings. Active your theme and plugins. Re-create your menu and configure your WordPress settings.

Final Results

So now you should know how to move a WordPress website from a localhost or from one hosting company to another. Also you particular host may have migration tools available, so check with them.

There is more to it than this, things like security, SEO, and domain email but this tutorial will get your WordPress website to the right location.

Resources

Root Directory

DNS

How DNS Works

WordPress Importer Plugin

WordPress.org


no2

One of an organizations most critical assets is their data.  It is like the DNA of the organization, nothing will work very well without it.  With so many ways for an organization to lose its data, you need a well implemented data backup and recovery plan.  If you fail to do this and then lose you data, you may well go out of business and you don’t want that to happen.

The backup plan consists of three phases:

  1. On-Site backups.
  2. Off-Site backups.
  3. Website backups.

However, with some many backup options available, I want to address the overall strategy.

On Site Backups

You need to have an on-site backup. On-site backups can be restored the easiest and you have complete control over them. The purpose of an on-site backup is two-fold.

  1. First it helps you when you accidentally deleted that file you need.  Well if you have an on-site backup, you can just open your backup and restore the file.
  2. The second purpose is for a full restore.  This could happen if a computer crashes, gets a virus, upgrading computers, etc.  You can just restore the entire backup to a new computer and you are set.

So should how the backup process work?  Well, you don’t really want to do this manually because you are likely to miss something (plus that would be a pain).  What you want to do is use some automated backup software.

Any good backup software will help you setup what needs to be backed up. Then it will begin by doing a full backup of everything you told it to backup.  Once that happens the software will detect changes and backup those files. One of the coolest features of this is if you need a copy of a file 3 versions ago, it will likely have it.

Depending upon the size of of your files the initial backup could take days, it really depends on the size of the files you have on your device, and how fast your device is.

One thing you should be aware of is that you should have a backup hard drive that is about 2x the storage space of the device’s hard drive. This is because of the way backups work they have to write a bunch of temporary files but if your backup drive doesn’t have the space it will fail (I speak from experience).

While I’m discussing hard drives, if you have the money, use a Solid State Drive (SSD) vs. a standard hard drive.  A solid state drive is faster and performs better, but they are more expensive.

Off-Site Backups

On-site backups are great for an easy restore but what happens when the backup gets destroyed at the same time as your computers?  If you have a flood, fire, robbery, etc. in your organization, this could happen.  That is why you need an off-site backup and for this, I recommend using the cloud.

Cloud based backup services are great because they don’t rely on you having to do much.  You essentially sign up, configure their software and it runs in the background.  Once it has done the initial full backup, it will backup incremental changes that it detects.

Some services will actually send you a hard drive through the mail to get the initial backup done quicker (vs uploading all your files through the internet, which is much slower).  To upload a large computer’s files to the cloud could take a few weeks, but once that is done it runs the incremental when it detects a change.

Also be aware that some service only do computers while others do computers, phones, tablets, etc.  When you are shopping for a backup service be sure of what type of devices they will actually backup.

Don’t Forget Your Website

One of the key elements for an organization is your website.  Remember, the website is open 24/7/365 never calls in sick, and can make sales for you at 3 AM when you are sleeping.  Make sure that you have a backup of it’s current state and a couple versions back.  Don’t rely on the host’s backup that you can get.  You need a copy as well (just in case).  You should have the content files, code files and database (this is a file called a .sql file). And remember, most websites these days, the lion’s share of the content is in the database.

Why go though this effort?  Because if you have an issue and need to make a change and you already have these, it will go much smoother. For example, if you developer is unexpectedly unavailable and you don’t have the technical knowledge to go retrieve the files from the host, that is a big problem. Part of the deliverable from your developer should be the website files.

I have had the unfortunate situation of helping organizations that have been hacked and didn’t have a recent backup to restore.  Lots of hours were spent re-typing the content from screenshots of the hacked website.

So if you have not yet implemented a backup plan for your organization (or your family) go make an investment in the proper equipment or services today.


Resources

Time Machine – part of the Mac OS.  If you own a Mac you have this already.

Windows backup and restore. Part of the Windows OS.  If you have Windows you have this already.

Carbonite – Coud backup service.

Mozy – Cloud backup service.

Please note, these are not affiliate links.  I don’t make any money if you click these links.  They are just services I am aware of.  I personally have used Mac Time Machine and Carbonite and have been pleased with both.

 

no2