From this case study you will learn
- why a backup on the same server does not protect against losing the server
- in what order we restore a Magento shop: database, media, configuration
- how a two-location backup with separate credentials works
- how to check that a backup really brings the shop back up
The shop ran on Magento 2 and served around one million customer accounts. The catalogue held tens of thousands of products, and traffic grew many times over during promotions. The whole platform ran on a single server: the application, the MySQL database, the media directory and the cron jobs.
The starting point
Backups existed on paper. Every night a script took a database dump and an archive of the media directory. The problem was where they went: both backups were written to a directory on the same disk as the shop. Nobody checked whether such a backup could bring the shop up on another server either.
What happened
The client lost access to the server. The shop went down, and every backup became unavailable together with the server. There was no second place to take the order database, customer accounts or product images from. Every hour of downtime meant lost orders and messages from customers who could not log in.
How we restored the shop
First we secured whatever could be recovered from the old server's disk and copied the data off it. In parallel we prepared a new server with the same versions of PHP, MySQL, Elasticsearch or OpenSearch and Redis that the shop used.
We restored the shop in a fixed order:
- the database from the last consistent dump,
- the pub/media directory with product images,
- app/etc/env.php and the service configuration,
- the application code in the version that matches the database.
After the restore we rebuilt the indexes and the cache. Before switching the DNS records we checked customer login, the basket, payments and order saving on a copy of the shop available only to the client team.
Backups in two places
Once the shop was back, we changed how backups are taken. A backup now follows two independent paths.
Local backup
It stays on the server and makes it quick to undo a bad change, for example a failed module update. It is not the only backup and does not protect against losing the server.
Off-server backup
It goes to separate backup storage in another location. It has its own account and keys, so someone with access to the shop server cannot delete it. It covers a consistent database dump, the media directory, the configuration and the code version. The database is backed up more often than media, because it changes with every order.
Monitoring checks the age of the latest backup in both places. If a job fails, an alert goes to an administrator.
Restore test
A backup only matters if the shop can be started from it. On an agreed schedule we restore the shop from the off-server backup to a separate test environment. We check login, the basket and order saving, and record how long it takes to bring the shop up.
Result
The shop is selling again on a new server. Losing the server no longer means losing the backups, because the most important backup lives outside it with separate credentials. The client knows how long a restore takes, because the procedure is tested regularly.
Summary
A backup on the same server protects against an application error, but not against losing the server. A shop with a million customers needs two independent backups, separate credentials and a regular restore test.
Write to us