In a WooCommerce e-shop, orders, customers and stock live in the database, so restoring the database to an earlier point deletes everything added after it. If the problem is in a plugin, theme or malicious code, restoring only the files and keeping the database as it is usually does the job. If the database has to go back too, first keep a copy of the current database and write down the orders that will be lost.
What is lost when I restore an e-shop database
The database goes back exactly to how it was at the time of the backup. Anything changed after that is lost:
- New orders and status changes on older ones, for example "Completed".
- New customer accounts.
- Stock movements from sales.
- Changes to products, prices and coupons.
Card payments made in the meantime are not cancelled. The customer has already been charged, the order simply no longer exists in the e-shop.
When restoring only the files is enough
The files contain the code of WordPress, the theme and the plugins, as well as the images. If the problem started with a code change, restoring only the files fixes it without touching the orders. Such cases are:
- A plugin or theme update that broke the site.
- Malicious code in PHP or JavaScript files.
- Files deleted or changed by mistake.
The database needs restoring when the problem is in the data itself. For example, when products were deleted, when a bulk update set wrong prices or when a plugin converted the database to a format its old version cannot read.
What you need before you start
- Access to cPanel. See the ways to log in to cPanel.
- The date and approximate time the problem appeared. You will pick a backup shortly before it.
- Access to the WordPress dashboard, if it still works.
Restoring only the files
- Log in to cPanel.
- Open JetBackup 5.
- Go to Restore & Download > Home Directory.
- Pick a backup dated before the problem.
- Select the e-shop folder, usually the whole public_html.
- Click Restore and confirm.
- Wait for the job to finish in the Queue.
If the cause was malicious code, restoring the files does not clean the database. Afterwards go to the WordPress dashboard, open Users and check there is no unknown account with the Administrator role. If you find one, delete it and change all passwords. The remaining steps are in the WordPress hack recovery guide.
Restoring files and database without losing order details
If the database has to go back too, first prepare for what will be lost.
- Put the shop in maintenance mode so that no new orders come in during the restore. In recent WooCommerce versions the setting is under WooCommerce > Settings > Site visibility, with the "Coming soon" option.
- Open WooCommerce > Orders and write down the orders placed after the time of the backup you will restore: number, customer, products, amount and payment method.
- Keep a copy of the current database. Open cPanel > Databases > phpMyAdmin, select the e-shop database in the left column, open the Export tab and click Export. Save the file on your computer.
- Restore the files with the steps of the previous section.
- Go to JetBackup 5 > Restore & Download > Databases.
- Select the e-shop database and a backup of the same date as the files.
- Click Restore and confirm.
- Wait for the jobs to finish in the Queue.
- Re-enter the orders you wrote down, manually from WooCommerce > Orders > Add order, and correct the stock.
- Take the shop out of maintenance mode.
Files and database must go back to the same date, otherwise WooCommerce may end up with code and data from different versions. The database copy you kept in step 3 lets a developer recover specific details from it if needed.
How to tell it worked
Open the e-shop in a private browsing window and go through a test purchase up to checkout. In the dashboard check that the order list starts from the order you expect. If you use LiteSpeed Cache, purge the whole cache.
Frequently Asked Questions
Why does the problem remain after restoring the files?
The cause is probably in the database, or the backup you picked is already after the problem. Try a slightly older backup or go on to restore the database too.
Why does JetBackup not accept another restore?
Up to 10 restores per hour are allowed and each files or database restore counts separately. See the JetBackup limits.
What if I am not sure what to restore?
Before restoring an e-shop database, open a ticket with the domain and the time the problem started, so we can look at it together. See how to open a support ticket.