Backups that actually work: the 3-2-1 rule applied to a store
Having backups is not the same as being able to recover the store. We explain what to back up, where to keep it and how to check that it works.
Everyone thinks they have backups until they need them. Then they discover that the backup is on the same server that has gone down, that it does not include the database or that nobody knows how to restore it.
The 3-2-1 rule
- 3 copies of the data (the original and two more).
- On 2 different media.
- 1 of them off your server and away from your hosting provider.
What to back up
- Database: orders, customers, products, configuration. It is the most valuable part and the one that changes most.
- Images (
img/): they can take up a lot of space, but without them the catalogue is empty. - Code: theme, modules, overrides,
app/config/parameters.php. - Downloads and uploads (
download/,upload/) if you sell virtual products or accept files.
Frequency
- Database: at least daily; in stores with many orders, several times a day.
- Files: daily or weekly, depending on how often they change.
- Before any update or module installation: always.
Consistent dumps
A database dump taken while the store is writing can end up inconsistent. With InnoDB tables, mysqldump --single-transaction solves this without locking the store.
The test almost nobody does
Once a quarter, restore a backup to a test environment and check that the store starts, that there are recent orders and that the images display. If you have never done it, you do not know whether you have backups.