Difference between revisions of "Restoring WHMCS"

From WHMCS Documentation

(Created page with "Data loss is a catastrophic but not unheard of occurrence. Good backups will turn a potentially disastrous situation into regrettable downtime, but if complete backups are not...")
 
 
(5 intermediate revisions by 4 users not shown)
Line 1: Line 1:
Data loss is a catastrophic but not unheard of occurrence. Good backups will turn a potentially disastrous situation into regrettable downtime, but if complete backups are not available for restoration, this guide shows how to restore a WHMCS installation from backups of its constituent parts.
+
Data loss is a catastrophic but not unheard-of occurrence. Good backup practices can mitigate the risks and turn a potentially-disastrous situation into manageable downtime.
 +
 +
If a complete backup is not available for restoration, you may need to restore with a database backup using the steps below.
  
The WHMCS is comprised of two main parts; the MySQL database which contains the settings and data, and the files which tell the software how to operate and control its appearance. Provided you have a backup of the database then most data can be salvaged, if you you also have a backup of the configuration.php file then all the data can be recovered.
+
== Data in WHMCS ==
 +
 +
WHMCS is effectively comprised of three key parts:
  
#The first step is to restore the database backup to your server. Database backups can usually be restored to your hosting account via a web interface such as phpmyadmin. Instructions for doing so are published in our documentation; [[Maintenance#Restoring_a_Database_Backup|Restoring a Database Backup]]
+
* The '''database''' contains all of the settings and data that WHMCS uses.
##Your hosting provider will be able to assist in this process if you run into problems.
+
* The '''files''' tell the software how to operate and control its appearance.
#Next you need to upload a fresh copy of the WHMCS full release files, these can be downloaded from http://download.whmcs.com or from your reseller.
+
* The '''configuration file''' allows the files to communicate with the database.
#Upload the configuration.php file from your file backups.
+
#You should then be up and running with WHMCS once again. Proceed to step 11.
+
Because the database itself contains all of the data, you can restore a WHMCS installation as long as you have a copy of that database. This uses the following process:
#If you do not have a backup of the configuration.php file then all password, security questions and credit card data will be scrambled. A new configuration.php file will need to be created using the template at the bottom of this guide.
+
#The license value should be filled with your full licence key.
+
# [[#Restore the Database Backup|Restore the database backup.]]
#The database connection details (username, password and name) should be entered
+
# [[#Replace the WHMCS Files|Replace the WHMCS files.]]
##Your hosting provider will be able to advise the values if you're unsure.
+
# [[#Replace or Creating the Configuration File|Replace or create the configuration file.]]
#The cc_encryption_hash value should be a random 50 character string comprising lowercase letters and numbers.
+
# [[#Perform Post Restoration Steps|Perform post-restoration steps.]]
#Save and upload the configuration.php file.
+
#You should then be up and running once again with most of your data in tact.
+
We recommend that you review all of the steps in this process (below) before you attempt to perform it on your WHMCS installation.
#Finally it will be necessary to re-create the [[Crons|cron job(s)]] and [[Email_Piping|email forwarders]].
+
 +
== Restore the Database Backup ==
 +
 +
The first step towards recovering from catastrophic data loss is to restore the database backup to your server.
 +
 +
You can usually restore database backups to your hosting account via a web interface like phpMyAdmin. For help with this process, contact your hosting provider or system administrator.
  
==Sample Configuration.php File==
+
To restore a database:
 +
 
 +
#Log in to phpMyAdmin and select the database you want to restore.
 +
#Select all tables by clicking '''Check all'''.
 +
#Choose ''Drop'' for '''With Selected'''.<br /><br />[[Image:Drop-tables.png|800px]] <br /><br />
 +
#Go to the '''Import''' tab: <br /><br />[[Image:maintenance1.png]] <br /><br />
 +
#Click '''Browse'''.
 +
#Find your backup file and press '''OK'''.
 +
#Click '''Go'''. <br /><br />[[Image:maintenance2.png]]
 +
 
 +
== Replace the WHMCS Files ==
 +
 +
Next, you must replace any missing WHMCS files. You can do this by downloading a new copy of the WHMCS full release files.
 +
 +
* If you purchased your license through WHMCS, download these from [https://download.whmcs.com/ Download WHMCS].
 +
* If you purchased your license elsewhere, request a new copy from your reseller.
 +
 +
Unzip the contents of the file to a folder on your computer and upload the contents from the <tt>whmcs</tt> directory to your existing installation folder.
 +
 +
== Replace or Creating the Configuration File ==
 +
 +
The WHMCS database stores encrypted and unencrypted data.
 +
 +
* Data that is not sensitive is unencrypted (for example, configuration settings, client details, and orders).
 +
* Sensitive data is encrypted (for example, credit card details, passwords, and security questions).
 +
 +
If you have a database backup, you can salvage all of the unencrypted data. You will need a backup of your configuration file (<tt>configuration.php</tt>) to recover the encrypted data.
 +
 +
=== Restoring an Existing Configuration File ===
 +
 +
If you have a backup of your <tt>configuration.php</tt> file, upload it to your installation directory.
 +
 
 +
You can then proceed to [[Restoring_WHMCS#Perform_Post_Restoration_Steps|performing the post-restoration steps]].
 +
 +
=== Creating a New Configuration File ===
 +
 +
If you do not have a backup of the <tt>configuration.php</tt> file, then all password, security questions, and credit card data will remain permanently encrypted and you will not be able to salvage it.
 +
 +
In this situation, you must create a new <tt>configuration.php</tt> file using the [[Restoring_WHMCS#Configuration_File_Template|Configuration File Template]].
 +
 +
* The '''license''' value should be the full licence key.
 +
* The '''db_host''' value should be the database hostname.
 +
* The '''db_username''' value should be the database username.
 +
* The '''db_password''' value should be the database password.
 +
* The '''db_name''' value should be the database name.
 +
* The '''cc_encryption_hash''' value should be a random 50 character string consisting of numbers and letters of varying cases.
 +
 +
If you are uncertain of the correct database connection details (<tt>db_host</tt>, <tt>db_username</tt>, <tt>db_password</tt>, and <tt>db_name</tt>), then your hosting provider will be able to advise which values should be used.
 +
 +
After you save the <tt>configuration.php</tt> file and upload it to your installation directory, your WHMCS installation should run with intact data.
 +
 +
=== Configuration File Template ===
 
<source lang="php">
 
<source lang="php">
 
<?php
 
<?php
$license="";
+
$license = "";
 
$db_host = "localhost";
 
$db_host = "localhost";
 
$db_username = "";
 
$db_username = "";
Line 27: Line 87:
 
$cc_encryption_hash = "";
 
$cc_encryption_hash = "";
 
$templates_compiledir = "templates_c/";
 
$templates_compiledir = "templates_c/";
?>
 
 
</source>
 
</source>
 +
 +
== Perform Post Restoration Steps ==
 +
 +
After restoring a WHMCS installation, make sure to review all configuration sections in the [[Admin Area]] and place a few test orders. We recommend the following steps:
 +
 +
# Log in to the WHMCS Admin Area.
 +
# If necessary, reset your admin password.
 +
# Review the following settings and configurations:
 +
#* Configuration settings at '''Configuration (<i class="fa fa-wrench" aria-hidden="true"></i>) > System Settings > [[General Settings]]''' or, prior to WHMCS 8.0, '''Setup > General Settings'''.
 +
#* Payment gateways at '''Configuration (<i class="fa fa-wrench" aria-hidden="true"></i>) > System Settings > [[Payment Gateways]]''' or, prior to WHMCS 8.0, '''Setup  > Payment Gateways'''.
 +
#* Servers at '''Configuration (<i class="fa fa-wrench" aria-hidden="true"></i>) > System Settings > [[Servers]]''' or, prior to WHMCS 8.0, '''Setup  > Products/Services > Servers'''.
 +
#* Domain registrars at '''Configuration (<i class="fa fa-wrench" aria-hidden="true"></i>) > System Settings > [[Domain Registrars]]''' or, prior to WHMCS 8.0, '''Setup  > Products/Services > Domain Registrars'''.
 +
#* Any [[Cron Jobs|cron jobs]] or [[Email Piping|email forwarders]].
 +
# Place some test orders on your website.

Latest revision as of 18:47, 3 May 2022

Data loss is a catastrophic but not unheard-of occurrence. Good backup practices can mitigate the risks and turn a potentially-disastrous situation into manageable downtime.

If a complete backup is not available for restoration, you may need to restore with a database backup using the steps below.

Data in WHMCS

WHMCS is effectively comprised of three key parts:

  • The database contains all of the settings and data that WHMCS uses.
  • The files tell the software how to operate and control its appearance.
  • The configuration file allows the files to communicate with the database.

Because the database itself contains all of the data, you can restore a WHMCS installation as long as you have a copy of that database. This uses the following process:

  1. Restore the database backup.
  2. Replace the WHMCS files.
  3. Replace or create the configuration file.
  4. Perform post-restoration steps.

We recommend that you review all of the steps in this process (below) before you attempt to perform it on your WHMCS installation.

Restore the Database Backup

The first step towards recovering from catastrophic data loss is to restore the database backup to your server.

You can usually restore database backups to your hosting account via a web interface like phpMyAdmin. For help with this process, contact your hosting provider or system administrator.

To restore a database:

  1. Log in to phpMyAdmin and select the database you want to restore.
  2. Select all tables by clicking Check all.
  3. Choose Drop for With Selected.

    Drop-tables.png

  4. Go to the Import tab:

    Maintenance1.png

  5. Click Browse.
  6. Find your backup file and press OK.
  7. Click Go.

    Maintenance2.png

Replace the WHMCS Files

Next, you must replace any missing WHMCS files. You can do this by downloading a new copy of the WHMCS full release files.

  • If you purchased your license through WHMCS, download these from Download WHMCS.
  • If you purchased your license elsewhere, request a new copy from your reseller.

Unzip the contents of the file to a folder on your computer and upload the contents from the whmcs directory to your existing installation folder.

Replace or Creating the Configuration File

The WHMCS database stores encrypted and unencrypted data.

  • Data that is not sensitive is unencrypted (for example, configuration settings, client details, and orders).
  • Sensitive data is encrypted (for example, credit card details, passwords, and security questions).

If you have a database backup, you can salvage all of the unencrypted data. You will need a backup of your configuration file (configuration.php) to recover the encrypted data.

Restoring an Existing Configuration File

If you have a backup of your configuration.php file, upload it to your installation directory.

You can then proceed to performing the post-restoration steps.

Creating a New Configuration File

If you do not have a backup of the configuration.php file, then all password, security questions, and credit card data will remain permanently encrypted and you will not be able to salvage it.

In this situation, you must create a new configuration.php file using the Configuration File Template.

  • The license value should be the full licence key.
  • The db_host value should be the database hostname.
  • The db_username value should be the database username.
  • The db_password value should be the database password.
  • The db_name value should be the database name.
  • The cc_encryption_hash value should be a random 50 character string consisting of numbers and letters of varying cases.

If you are uncertain of the correct database connection details (db_host, db_username, db_password, and db_name), then your hosting provider will be able to advise which values should be used.

After you save the configuration.php file and upload it to your installation directory, your WHMCS installation should run with intact data.

Configuration File Template

<?php
$license = "";
$db_host = "localhost";
$db_username = "";
$db_password = "";
$db_name = "";
$cc_encryption_hash = "";
$templates_compiledir = "templates_c/";

Perform Post Restoration Steps

After restoring a WHMCS installation, make sure to review all configuration sections in the Admin Area and place a few test orders. We recommend the following steps:

  1. Log in to the WHMCS Admin Area.
  2. If necessary, reset your admin password.
  3. Review the following settings and configurations:
    • Configuration settings at Configuration () > System Settings > General Settings or, prior to WHMCS 8.0, Setup > General Settings.
    • Payment gateways at Configuration () > System Settings > Payment Gateways or, prior to WHMCS 8.0, Setup > Payment Gateways.
    • Servers at Configuration () > System Settings > Servers or, prior to WHMCS 8.0, Setup > Products/Services > Servers.
    • Domain registrars at Configuration () > System Settings > Domain Registrars or, prior to WHMCS 8.0, Setup > Products/Services > Domain Registrars.
    • Any cron jobs or email forwarders.
  4. Place some test orders on your website.