Your message has been sent.
This article has been saved to your account.
Go to my account
This article has been emailed to your Kindle.
Send this article
Complete the form below to send this article, Upgrading OpenCart, to a friend (or to yourself). We will never share your details (or your friend's) with anyone. For more information, read our Privacy Policy.
It is wise to update our OpenCart environment to the latest version regularly. It protects our system against security vulnerabilities and allows us to use new features. It is also possible that the new OpenCart version will have several bug fixes.
Moreover, new versions can have new bugs. Because of this, it is a common practice to wait while a version with major changes matures and gets rid of serious bugs with minor release fixes.
In this article by Murat Yilmaz, author of OpenCart 1.4 Beginner's Guide, we shall learn about:
- Making a backup of current OpenCart system
- Downloading the latest OpenCart version
- Uploading the new files to a server
- Running the upgrade script
- Checking whether everything works as expected or not
- Restoring the OpenCart system if an upgrade fails or has serious problems
This article is suggested reading even for an experienced user. It will show us any possible problems that might occur while upgrading, so we can avoid them.
Making backups of the current OpenCart system
One thing we should certainly do is backup our files and database before starting any upgrade process. This will allow us to restore the OpenCart system if the upgrade fails and if we cannot solve the reason behind it.
Time for action – backing up OpenCart files and database
In this section, we will now learn how to back up the necessary files and database of the current OpenCart system before starting the upgrading processes.
We will start with backing up database files. We have two choices to achieve this.
The first method is easier and uses the built-in OpenCart module in the administration panel.
- We need to open the System | Backup / Restore menu.

- In this screen, we should be sure that all modules are selected. If not, click on the Select All link first. Then, we will need to click on the Backup button.

- A backup.sql file will be generated for us automatically. We will save the file on our local computer.

The second method to backup OpenCart database is through the Backup Wizard on cPanel administration panel which most hosting services provide this as a standard management tool for their clients. If you have applied the first method which we have just seen, skip the following section to apply. Still, it is useful to learn about alternative Backup Wizard tool on cPanel.
- Let's open cPanel screen that our hosting services provided for us. Click on the Backup Wizard item under the Files section.

- On the next screen, click on the Backup button.

- We will click on the MySQL Databases button on the Select Partial Backup menu.

- We will right-click on our OpenCart database file backup and save it on our local computer by clicking on Save Link As.

- Let's return to the cPanel home screen and open File Manager under the Files menu.

- Let's browse into the web directory where our OpenCart store files are stored. Right-click on the directory and then Compress it.

- We will compress the whole OpenCart directory as a Zip Archive file.

- As we can see from the following screenshot, the compressed store.zip file resides on the web server. We can also optionally download the file to our local computer.

What just happened?
We have backed up our OpenCart database using cPanel. After this, we also backed up our OpenCart files as a compressed archive file using File Manager in cPanel.
New OpenCart version
Until OpenCart v1.4.7, we had to upgrade our system manually. Each new version included an upgrade.txt file to read first and apply upgrades manually.
For example, this is a screenshot from the v1.4.6 upgrade.txt file:

Now, starting from v1.4.7, we are able to use a universal upgrade script without opening the phpAdmin tool to execute the SQL scripts manually. The web based script supports upgrading from any version later than v1.3.0 to v.1.4.7 directly.
If we are using a version older than OpenCart v1.3.0, we will need to first upgrade all the versions in between until we reach 1.3.0. Then we can run this script.
Now, let's learn how we will use the upgrade script.
Time for action – downloading the latest Opencart files, uploading them to the server, and upgrading
We will now learn how to download the latest version of OpenCart and upload to our server. Then, we will run upgrade script.
- Let's browse into
http://www.opencart.com/index.php?route=download/downloadWe will save latest OpenCart zip file on our local computer.

- Now, let's click on the Extract Here menu item to extract all the contents of a folder.

- We need to delete default, and empty the config.php file in the upload folder in our local computer.
Do not delete the config.php file on your web server by mistake.

- We also delete the config.php file, which resides in the upload/admin folder in our local computer.

- Now, let's add all the files in the upload folder into an upload.zip archive file on our local computer.

- Let's upload the upload.zip file where our store files are on the web server. Then, let's Extract all the contents to the same folder on the web server. We should allow re-writing of all files if we get a message about doing it.
The other solution would be deleting all files on the server except config.php and extracting the new files there.

- After the extraction is complete, let's browse into http://www.yourwebsite.com/store/install/upgrade.php path. Here, we have assumed our OpenCart installation is under /store directory. If our store files are under root folder of the website, we should browse into
http://www.yourwebsite.com/install/upgrade.php.The script will run and inform us about the result. The following screenshot shows the success page:

- Let's browse into the storefront now and be sure that everything is working as expected. Also, let's open the administration panel and check the system settings. If there are any changes, let's apply them to the needed settings back.
What just happened?
We have downloaded the latest OpenCart version to our local computer. We have extracted the contents of the archive file and deleted two config.php files which reside in the upload and upload/admin folders.
Then, we re-packaged all the upload folder content as upload.zip. The next step was to upload the upload.zip file to our webserver and extract this archive. We have re-written all files with the new versions. We have run the upgrade script and have seen the results of the upgrade process.
Finally, we have controlled all functionality of the OpenCart system, both on the storefront and on the administration panel menus.
Have a go hero – exploring config.php files
Now, go and download the config.php files both from the store root and admin folders. Open them with any word editor and explore the contents. They include several path definitions which OpenCart uses and your database connection information.
Restoring to the original OpenCart version
No software is completely perfect, and OpenCart is no exception. Any upgrade process can fail partially or completely. This is especially true if we have manual changes on OpenCart system files, database structure, or have used several third party mods in the system. We will now see how we will use backup files to restore our OpenCart system when needed.
Time for action – restoring OpenCart system if upgrade fails
In this section, we will now learn how to replace OpenCart files and restore the database.
- Let's open File Manager in cPanel and find where our OpenCart files are located. In this case, they are in the store folder. Let's delete it.

- Let's upload our backup store.zip file here and extract the contents.

- We now have old OpenCart files which are retrieved from the backup file, as we can see from the following screenshot:

- We can use the built-in Restore tool of OpenCart. Let's browse into the System | Backup | Restore menu. After that let's choose the backup.sql files which we have previously saved in our local computer. All we need to do finally is to click on the Restore button on the top of the screen.

If you have used the first method of restoring OpenCart database, you can skip the following section. Still, you can read it to increase your knowledge on cPanel Backup Wizard.
- Let's open Backup Wizard on cPanel. It is under the Files menu.

- We will need to click on the Restore button to continue.

- Let's click on the MySQL Databases button on the Select Restore Type menu.

- We will need to browse the OpenCart database backup file which we have already backed up before. After this, let's click on the Upload button.

- The restore wizard will run the contents of the SQL file in the archive. It will drop all tables in this database, recreate them, and reinsert all of the values.

- Now, we should check both the storefront and administration settings manually to be sure that every functionality works as expected.
What just happened?
We first deleted all OpenCart files. Then, we have uploaded the backup file and extracted the contents. So, we have finished restoring files. We have opened the Backup Wizard in cPanel and uploaded a database backup through the wizard. It has run and overwritten our database to old values which are retrieved from the SQL backup file.
Summary
As we can see, upgrading OpenCart is not a difficult task thanks to new upgrade script, but the upgrade process still needs a careful execution order. The most important thing is to back up files and the database beforehand. Also, we should be careful about not to overwrite working config.php files with the empty config files that come with new versions.
In this article, we learned how to upgrade OpenCart on a web server and restore the old system if an upgrade fails.
About the Author :
Murat Yilmaz
Murat Yilmaz is a software developer and an online entrepreneur who lives in Antalya, Turkey. He has over 10 years of experience in different IT fields, including development of web-driven solutions, large databases, and OLAP systems. He has worked in several multinational companies in Istanbul and Moscow as a consultant. He currently runs his own blog and an e-commerce and online advertising network. He holds a bachelor's degree in Computer Science from Marmara University at Istanbul. He spends his free time playing progressive rock songs, online chess, and reading scientific books.
He has also authored two other books, OpenCart 1.4: Beginner's Guide and OpenX Ad Server: Beginner's Guide.



Post new comment