How to Backup and Restore a Database in Prestashop

PrestaShop is a php/MySQL driven application which relies on its database for storing different type of information across the large amount of database tables it has. From time to time you might want to backup or restore the database of your Store in case of some major issue with the same. Currently PrestaShop Hosting fully includes automatic backup for the files and folders of your account, however just to ensure that you will have a backup in a point of time when your Store is in good shape this guide takes you through the steps you undertake to do that.

To backup and restore your PrestaShop database, you will need to:

Step 1: Backup the Database

  • Accessing the DB backup page
  • Generating a database backup
  • Downloading the generated database backup

Step 2: Restore the Database

  • Accessing already generated backups
  • Accessing phpMyAdmin
  • Accessing the importing feature
  • Configuring the importing of your database
  • Accessing the cPanel File Manager
  • Editing the configuration file

Why is a Database Backup Necessary

  • 1. Guard Against Human Error
  • 2. Reverse Problems During Updates
  • 3. Prevent Loss of Data
  • 4. Handle Compatibility Issues After New Installations
  • 5. Resolve Malware Infections
  • 6. Provide Protection Against Hackers
  • 7. Simplify the Process of Migrating Web Hosts
  • 8. Make It Easy to Create a Testing Version of Your Website
  • 9. Ensure an Uninterrupted Revenue Stream
  • 10. Foster Strong Security Practices

Read more PrestaShop Tutorials:

Basic Steps to Take After a PrestaShop Installation

How to install PrestaShop on a Live Website

Manage Products in PrestaShop

Step 1 Backup the Database

There are few ways to backup up the database used by your website. The best however we find the one provided by the authors of the PrestaShop application. In order to use that backup method you should login into the Back office of your Store and then navigate to Advanced Parameters>DB Backup.

Accessing the DB backup page

This is an actual dedicated page from the Back Office of the PrestaShop application which will grant you the option to perform a full scale backup of your database. Let’s proceed with the generation of the actual backup. As you proceed, you will be provided with detailed information on the backup process under the Disclaimer section and there you will also find the “I have read the disclaimer. Please create a new backup.” button which you should use for the backup generation process to be started.

Generating a database backup

As soon as you click on that button the page will be reloaded and at the top of the same you will notice a message indicating the successful backup you have just performed and also a button labeled Download the backup which will allow you to actually download the backup.

Downloading the generated database backup

Once you click on that button your download will begin immediately so you can have a fresh backup of your database.

Read more PrestaShop Tutorials:

PrestaShop Store Configuration Tutorial

PrestaShop Store Management Tutorial

Step 2 Restore the Database

In order to restore a backup you will need to first download the same or in case you have already downloaded it when the same was generated you can proceed with the restoration after the following explanation on how to obtain a backup copy of your database.

When a backup of the database is generated via the Back Office of your Store it will be stored in the admin folder and more precisely in the backups folder located inside the admin folder. In order to obtain a copy of the generated backup you have two choices:

You can access the backup generation page and if you scroll down to the bottom of the page you will find the DB Backup table view which will actually show you the already generated backups for the database of your Store. If you click on the View button next to every backup your download process will begin and you will be able to obtain the copy.

Accessing already generated backups

The second option you have for obtaining a backup is to login into the FTP service for your account and to navigate to the mentioned backup folder (adminXXX/backups) where you will be able to find all those backups archived for easier download.

No matter which the two options will be chosen you will always end up with a downloaded copy of your database.

Now that you have the backup it is time to restore the same. Unfortunately the authors of the PrestaShop application did not include any restoration feature in the Back Office of the application and for this reason you will need to use the good old restoration method for any database.

The method is relatively simple as you will need to create a new database via your cPanel>MySQL Database Wizard and then to import the downloaded .sql file. Let’s review that process in details.

First in order to create a new database using the MySQL Database Wizard feature you should follow our Create MySQL Database and User via cPanel hosting tutorial. There you will find quite a detailed review of the process so you can end up with a database name, database username and of course a database password.

Secondly in order to import the downloaded .sql file you will need to use the phpMyAdmin feature provided in the cPanel service included in every PrestaShop Hosting package. You can find the feature in the Databases section.

Accessing phpMyAdmin

Once you access the feature you will need to locate the database you have just created. Usually this database will be listed in the left vertical navigation panel along with all other databases for your account. As soon as you locate the newly created database please click on the same so you can be presented with the table view for this database and then click on the Import button located at the top horizontal menu.

Accessing the importing feature

This will bring the importing interface where you will be able to Choose File in order to point the browser to the downloaded .sql file for your database. Next you will need to simply hit the Go button so the importing procedure can begin.

Configuring the importing of your database

Once the importing is finished you will be provided with a message indicating the successful import and the amount of queries being executed against the newly created database.

The only thing left to do is to reconfigure your PrestaShop based store with the database you have just created and which you have imported the backup into. For this purpose you will need to edit the main configuration file of the PrestaShop application. This can be achieved quite easily via the cPanel>File manager feature.

Accessing the cPanel File Manager

Once you access it you will need to navigate to the folder where your store is currently installed. Usually if your store is accessible directly on your primary domain your PrestaShop should be installed into the public_html folder. Once you access the folder where the installation is performed you will need to locate the config folder where you will find the file. The is the file you should be editing in order to configure your Store with the new database you have restored.

Editing the configuration file

Please right-click on that file and choose the Code Edit option so you can be presented with the code editing tools of the File Manager service. Then on the top of the file you will be able to find the following lines:

define('_DB_NAME_', database_prest37');
define('_DB_USER_', 'database_prest37');
define('_DB_PASSWD_', 's0m3p@ssw0rd');


Here you will need to change the lines respectively with database name, database username and the database password used by your newly created database. Once you are ready with the edits please save the file by using the “Save” button located at the top right corner of the code editing tool and you are done.

Now please refresh your website and see the result of your work.


Why is a Database Backup Necessary

1. Guard Against Human Error

Everyone makes mistakes from time to time. You might delete an important file on your website, make a change that breaks some of its functionality, and so on. There are ways to fix these kinds of errors, but in our experience, few are as efficient as restoring a previous backup.

To put this into perspective, imagine that a significant part of your website ceases to work. You have two options:

  1. Identify the problem and look for a way to solve it.
  2. Restore your website’s most recent backup and move on.

The first method can be quick or take a lot of time, depending on how serious the problem is. However, with the second approach, you can have your site up and running quickly. All you need is a recent enough backup that you won’t lose any valuable data.

The primary takeaway is that backups can save you in situations where you or someone else makes a mistake on your site. To be as safe as possible, you’ll want to create those backups frequently — even on a daily basis.

2. Reverse Problems During Updates

Updates are necessary to keep your site functioning smoothly. At the same time, it’s not uncommon to perform an update to your site, only to see something unexpectedly go wrong. That doesn’t mean you shouldn’t make changes — you just have to go about them safely.

Ideally, you’ll have an automatic backup system set up for your site. That way, if you update any of its key components, you’ll have a recent restore point available just in case. It’s also smart to make a manual backup before you start tinkering with your website.

It might take you a few minutes or longer to get that backup ready. However, you’ll be happy you made the time if anything goes wrong during the update process.

3. Prevent Data Loss

Imagine that you have a blog with hundreds of posts, and someone on your team deletes one (or more) of them by mistake. In the past, we’ve seen people delete entire libraries of content because they didn’t know what they were doing or they gave certain users too many privileges.

One of the primary reasons to maintain a backup system is to ensure that your data will be safe, even in situations like this. That means you need to have a full backup of your site in place, and the same goes for your personal data as well.

Data loss can occur even if there’s no human error involved. That means having backups is essential, even if you and your team know what you’re doing.

If you’re worried about losing important data, we recommend you take things one step further. Not only should you have multiple backups available, but you should also avoid keeping them all stored in the same location. We recommend downloading your latest backups to a safe hard drive or to the cloud, as well as keeping a copy on your server for redundancy’s sake.

4. Handle Compatibility Issues After New Installations

If you use WordPress or any other Content Management System (CMS), then you probably rely a lot on add-ons, such as themes and plugins. Both types of tools can be incredibly handy. However, each time you install a new add-on, you’re introducing an element that might not play nicely with the rest of the site’s ecosystem.

Just as with updates, this doesn’t mean you should avoid plugins and themes. Instead, what you need to do is be careful about the ones you install. Make sure they have good reviews and ratings, and that the developers update them frequently.

You’ll also want to back up your website before you activate a new theme or WordPress plugin, just to be safe. With this approach, if a compatibility issue pops up, all you have to do is revert to a previous backup. Then, you’re free to install an alternative tool.

5. Resolve Malware Infections

A lot of people think of malware as something that can only affect personal computers. However, a surprising number of websites are infected with some kind of malware, and a lot more of them are vulnerable to it.

Even if you’re proactive about website security, attackers have highly-sophisticated techniques in their arsenals. Also, keep in mind that not even smaller, lesser-known websites are safe from attacks. WordPress users, for example, often face threats from bots looking for vulnerabilities they can exploit.

Troubleshooting malware can be particularly tricky since it’s hard to know when your site is fully clean. Even then, if you don’t identify and patch the security ‘hole’ that led to the infection, you’ll remain vulnerable. Having a backup ready to go will help you get your website clean faster.

6. Provide Protection Against Hackers

There may also be times when attackers try to access your site directly to deface it or steal important information. If someone manages to breach an account with administrative privileges, for example, they might change its credentials to lock you out of your site.

This shouldn’t happen if you take the right security precautions. It’s especially critical to have Two-Factor Authentication (2FA) enabled on your site. If there is a hack, however, there are three ways you can proceed:

  1. Try to recover access to your account through your email.
  2. Contact your web hosting provider to ask for their assistance.
  3. Restore a backup from your hosting panel.

The first option might not always work since attackers will probably change the email associated with the account right away. If you’re using a reputable web host, the company should be able to help you — but that can take time.

Restoring a backup, on the other hand, can help you regain control of your site quickly. Once you do, you can update your credentials to ensure that attackers are locked out once more.

7. Simplify the Process of Migrating Web Hosts

In a perfect world, you wouldn’t need to switch web hosts. However, a lot of people make the mistake of choosing the first provider they run into that looks decent. It does not always end up so good

This means you may need to migrate from one web host to another at some point. The process involves moving all of your site’s files from one server to another. The good news is that if you’ve taken our advice to heart, you already have multiple full copies of your website ready to go.

There are a lot of ways you can use backups to migrate your website. You can copy files manually, use dedicated tools, or ask your new provider to do it for you. In any case, having a backup ready means that you can switch web hosts at a moment’s notice if you need to, which gives you a lot of freedom.

8. Make It Easy to Create a Testing Version of Your Website

Whenever you want to make a significant change to your site, the safest way to do so is by using a testing environment. That way, if something goes wrong during or after the update, you can keep it from affecting your live website.

To do this, you’ll need what’s called a staging site. There are several ways you can go about creating one, and they’re all pretty straightforward. What’s more, having a recent backup of your site in place means you can be ready to set up a staging copy in minutes.

9. Ensure an Uninterrupted Revenue Stream

If you make money from your website, then you need to ensure that it’s always accessible. Every minute that it isn’t working can cost you money. Just to give you an idea of the stakes, Amazon estimated that a little downtime during its Prime Day event cost it anywhere between $72–$99 million.

If you run a small business, you’re probably not working with those kinds of numbers. However, that means it’s even more important not to lose out on any potential earnings due to problems with your website. An hour’s (or a day’s!) lost income can be a significant blow to any business.

Troubleshooting unexpected problems from scratch can take a lot of time, as we mentioned before. On the other hand, if you can restore a backup, you’ll get your website back online and earning money quickly. Then you can take your time to find out what went wrong in the first place and keep it from happening again.

10. Foster Strong Security Practices

If we had a dollar for every time we recommended that website owners back up their data, we’d be millionaires. However, if you took a dollar away for every time someone ignored that advice, we might break even.

The fact is that backups are about as versatile as sliced bread. Plus, you have so many options for how to back up your site that there’s no excuse not to do it. Backing up your data, in general, is the cornerstone of good digital security.

If you take your website seriously, you’ll also want to read up on the other best security practices you can implement. However, the first step is to create a backup right away and repeat the process often. Sooner or later, it will save your site so now’s the perfect moment to start.

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

How to install PrestaShop on a Live Website

In this tutorial we'll show you how to install PrestaShop 1.7 and above on your web hosting plan...

Basic Steps to Take After a PrestaShop Installation

Once you have completed the installation of our Prestashop website and created your online...

Manage Products in PrestaShop

In this post, we cover all aspects related to adding, editing and the entire product management...

PrestaShop Store Configuration Tutorial

Once you have your PrestaShop store successfully installed, you should settle down to properly...

PrestaShop Store Management Tutorial

Here we take a detailed look at the various actions and steps required to setup a PrestaShop...

Powered by WHMCompleteSolution