A complete OpenCart backup consists of two parts: a database dump (products, orders, customers, settings) and a copy of the site files (images, theme, modules, configs). Copies should be created automatically, stored off the store's server, and checked regularly with a test restore. Without verification, a backup guarantees nothing.
What exactly should you copy in an OpenCart store?
An OpenCart store keeps its data in two places, and losing either one is painful.
The database (MySQL or MariaDB) contains the catalog, prices, stock levels, orders, customers, coupons, SEO URLs, module settings, and all parameters from the «Settings» section. This is the most valuable part: you can't recreate last week's orders from scratch. Which tables are responsible for what is described in the article on the OpenCart database table schema (in the wiki: OpenCart database table schema).
Files include:
image/: product photos, banners, logo. Usually the heaviest folder, from hundreds of megabytes to tens of gigabytes.config.phpandadmin/config.php: paths, site address, database access. What they contain is covered in the material on OpenCart file configs.- Theme:
catalog/view/theme/(in 3.0) orcatalog/andview/ template/ extension/{код}/(in 4.1); installed modules:extension/(in 4.1) or module files inadmin/andcatalog/(in 3.0). - The
storagedirectory: modifications, files uploaded by customers, logs. There's no need to copy the cache. For details, see the article on the storage directory. .htaccessand, if present, any custom core modifications.
A common mistake is copying only the database for years. After a crash or disk failure, the data is intact, but photos, the theme, and paid modules with your customizations are gone. Recovery then takes weeks.
Is OpenCart's built-in backup enough?
The admin panel has a tool called «System → Maintenance → Backup / Restore». It works only with the database, and it behaves differently in the two branches.
In 3.0, you check the tables with checkboxes, and the browser immediately downloads an SQL file. Everything happens in a single request, so on a large database (tens of thousands of products, years of orders) the process often breaks off because of the PHP execution time or memory limit. The file may turn out to be truncated, and nothing will warn you about it.

In 4.1, the copy is created in parts via AJAX. The finished file is stored on the server in storage/backup/, and from the list you can download, restore, or delete it. This works more reliably with large databases, but the copy sits on the same server as the store.

An important nuance: the built-in backup essentially exports data (emptying a table and inserting rows), not the full database structure. It can only be restored into a database where the OpenCart tables already exist. Such a file won't deploy onto an empty server «from scratch».
How do you set up automatic backups of the database and files?
A reliable option is a script on the server that runs via cron (the Linux task scheduler). It's needed on a VPS, and it also works on most hosting plans with SSH access. If there's no SSH, check whether your hosting control panel can make scheduled copies, and be sure to download them to your own machine (more on this below).
Step 1. Store database access separately from the script
So that the password doesn't show up in the process list, put it in the ~/.my.cnf file with permissions 600:
[mysqldump]
user=shop_user
password=ваш_пароль
Step 2. The backup script
#!/bin/bash
DATE=$(date +%F_%H%M)
DIR=/home/user/backups
SITE=/home/user/public_html
DB=shop_db
mkdir -p "$DIR"
# База: --single-transaction дає цілісну копію для InnoDB (4.1)
mysqldump --single-transaction --quick --routines \
--default-character-set=utf8mb4 "$DB" | gzip > "$DIR/db-$DATE.sql.gz"
# Файли без кешу
tar -czf "$DIR/files-$DATE.tar.gz" \
--exclude="./system/storage/cache" \
--exclude="./image/cache" \
-C "$SITE" .
# Перевірка, що архів бази не битий
gzip -t "$DIR/db-$DATE.sql.gz" || echo "DB backup broken $DATE" >> "$DIR/errors.log"
# Видалити копії, старші за 14 днів
find "$DIR" -name "*.gz" -mtime +14 -delete
For 3.0, where tables are usually in MyISAM, --single-transaction does not guarantee consistency. Run the dump at night, when there are almost no orders, or remove this flag so that mysqldump locks the tables during copying. If storage is moved outside the site (which is recommended), add its path to the archive separately. image/cache is not copied: OpenCart will regenerate the thumbnails.
Step 3. The cron schedule
30 3 * * * /home/user/bin/backup.sh >/dev/null 2>&1
This makes a copy every night at 3:30. For a store with dozens of orders a day, it's worth copying the database more often, for example every 4–6 hours, while files are fine once a day. OpenCart's internal tasks are described in the article on cron in OpenCart, but for backups the system cron is more reliable: it doesn't depend on whether the PHP site is alive.
Where should you store copies, and how many should you keep?
A copy on the same server protects you from a failed module update, but it won't help if the hosting account is hacked or suspended, the disk burns out, or the data center loses power. For stores in Ukraine, the last risk is quite real, so the plan for outages is covered separately in the security section. A proven rule is 3-2-1: three copies, on two different media, one off the main site.
| What | How often | Where to store | How long to keep |
|---|---|---|---|
| Database dump | 1–4 times a day, depending on the number of orders | Server + cloud storage | Daily for 14 days, monthly for half a year to a year |
| Files without cache | Daily or weekly | Cloud storage | 2–4 weeks |
| Full copy before an update | Before every change | Local + cloud | Until the next stable state |
| Host snapshot | Per plan | Host's infrastructure | As the plan allows |
For uploading to the cloud, a convenient utility is rclone. It works with Google Drive, Dropbox, and S3-compatible storage. Just add the rclone copy "$DIR" remote:shop-backups --max-age 24h line to the script. The storage account should be separate from the one you use to manage the site: if an attacker gains access to the server, they should not be able to delete the remote copies as well.
Long-term retention is needed because infections are often noticed late. Malicious code can sit in files for weeks, and then yesterday's copy will be infected too. Monthly copies are exactly what saves you in a store hacking scenario.
How do you check that the backup actually restores?
Most owners find out their backup is unusable on the day of the disaster: the dump is truncated, the archive is empty, the encoding is broken, and nobody remembers the storage password. So once a month or quarter, run a test restore on a separate subdomain.
- Create a subdomain such as
test.shop.uaand a new empty database. - Download the latest archive from the storage, not from the server. This way you also verify the upload.
- Import the dump:
gunzip -c db-....sql.gz | mysql test_db. - Unpack the files and edit both
config.php: the site address, theDIR_*paths, and access to the new database. What else to change when the address differs is described in the post on changing the site address in OpenCart. - Protect the test copy from indexing and outsiders: with a password via .htaccessAn Apache configuration file required for SEO-friendly URLs. After installation, rename .htaccess.txt to .htaccess. More in the glossary → or by restricting by IP.
- Turn off email sending and payment modules, so the test copy doesn't send emails to customers or connect to the acquirer.
What to check on the restored copy
- The home page, a category, and a product pageThe page for a single product: photos, price, options, description, reviews. More in the glossary → open, and photos load.
- Admin login works, and «Sales → Orders» (Sales → Orders) contains orders from the day before the backup.
- The number of products and customers matches the live site.
- Cyrillic in names and descriptions displays without garbled characters.
- In 3.0, modifications apply after «Refresh», and modules are in place under «ExtensionsAdditional functionality: a module, a payment or shipping method, a feed, or a theme. They are managed in "Extensions → Extensions." More in the glossary → → Extensions» (type «Modules»).
If the site shows a white screen, look for the causes in the guide on the 500 error in OpenCart. The most common culprits are incorrect paths in the configs or a different PHP versionThe language version on the hosting. 3.0.4.1 requires at least PHP 7.3, while 3.0.5.1 and 4.1.0.4 require at least PHP 8.1; check extension compatibility before updating. More in the glossary →. Note how long the restore took: that is your real downtime during an emergency.
When is an off-schedule backup essential?
Besides the daily schedule, there are moments when the risk rises sharply and a fresh copy is needed «right here and now»:
- before installing or updating a module, theme, or modification;
- before a mass import of products or prices, because a faulty column mapping can overwrite thousands of items;
- before updating OpenCart or the PHP version on the hosting;
- before moving to another host or domain (see the store migration plan);
- before running manual SQL queries in phpMyAdminA web interface to the database. Make a dump before any changes. More in the glossary →.
For such cases, the simplest approach is to run the same script manually and make sure the files appeared and have a reasonable size. A sharp drop in dump size compared to yesterday is a warning sign. On a small database, you can also use the built-in «Backup» in the admin panel, but only as a supplement.
Finally, write the restore procedure into a simple document: where the copies are, how to access the storage, who has SSH, and which steps to follow. Keep it not only on the store's server. In a stressful situation, such instructions save hours.
Other topics on protecting your store are collected in the section "Security, Backups and Protection".
Summary
- An OpenCart backup always means the database and the files:
image/, configs, theme, modules, storage without cache. - The built-in "Backup" tool copies only database data and suits one-off copies before changes, but not as a primary system.
- Automate copies with mysqldump, tar, and cron, and for InnoDB in 4.1 use
--single-transaction. - Keep copies off the server, in a separate account, encrypted, with a history depth of at least several weeks.
- Regularly restore a copy on a test subdomain and note the time. Without this, you don't know whether you have a backup.
Next step: go through the general OpenCart security checklist, so that your backup remains the last line of defense, not the only one.