Runbook: restore from backup
For system administrators who must bring a customer site back from a backup: after data loss, a broken update or a compromise. The procedure is that of 10.9 Backups and restore; this page arranges it for an incident.
Contents
Decide first
| Question | Why |
|---|---|
| Which backup? | The newest one from before the problem started; for a compromise, one from before the attacker's first change (Compromised site). |
| Everything, or only the database, or only some files? | A restore of everything loses all content published since the backup. |
| What is lost? | Publishing between the backup and now. Tell the customer before you start. |
| Where? | In place, or first on a second machine to check the backup (preferred when time allows). |
Tip
Keep the damaged state. Before restoring over it, take a copy of the current database and files; it may be needed to recover content published after the backup or to investigate.
Prepare
Copy the current state aside (database dump and files), as above.
Maintenance mode on, so visitors get a 503 page and nobody publishes:
php bin/php/maintenance.php on --message="Restoring the site" --until=1h --allow-root-userUnder Velocity, stop the server so no worker holds the old database:
php bin/php/console exp:velocity stop --allow-root-user
Restore
The database, with the tool of its engine (official order):
Engine Restore 1. SQLite 3 sqlite3 var/storage/sqlite3/exponential.db ".restore '/backup/db.sqlite'"; never copy over a file in use2. PostgreSQL pg_restore -U USER -d DATABASE --clean /backup/db.dump3. MongoDB mongorestore --uri="..." --drop /backup/mongo4. MariaDB mariadb -u USER -p DATABASE < /backup/db.sql5. Oracle php bin/php/console ext:ezoracle:datapump --import=db.dmp, or Oracle'simpdp6. MySQL mysql -u USER -p DATABASE < /backup/db.sqlSources: 10.9 and Database support.
-pmakes the client ask for the password; never write it on the command line.The files: unpack
var/storage(andvar/<site>/storage), and if neededsettings/overrideandsettings/siteaccess, over the installation.Owners and modes: the files must belong to the site's user as the engine or PHP-FPM pool expects (Writable directories and permissions).
Caches and autoloads:
php bin/php/ezcache.php --clear-all --allow-root-user php bin/php/ezpgenerateautoloads.php -eStart Velocity and clear its response cache:
php bin/php/console exp:velocity start --allow-root-user php bin/php/console exp:velocity cache clear --apply --allow-root-userUnder PHP-FPM, reload the site's PHP-FPM service.
Verify and reopen
Open the front page and the administration through a hosts-file entry or with maintenance mode letting your address through (
--allow-ip, see Maintenance mode).Sign in, open recently changed content, upload a test image, run a search.
Check
var/log/error.logfor new errors:./console exp:logs --tail=var/log/error.log --lines=50.Maintenance off:
php bin/php/maintenance.php off --allow-root-user
After the incident
- To do: Tell the customer what was restored, from which time, and what must be published again.
- To do: If the search index looks incomplete, rebuild it (
php bin/php/updatesearchindex.php; see Search backends). - To do: Record how long the restore took: that is your real recovery time for the SLA (SLA options).
- To do: Keep the copy of the damaged state as long as your policy says, then delete it.
Related pages
- Restore and restore tests
- Database backups per engine
- Compromised site
- Free documentation: this page is free to copy, translate and improve under the GNU FDL 1.3.
Become an Exponential Partner
Partners share their information, provide funding, contribute back and develop the products with us, and that is how Exponential grows. A partner website and dashboard are planned for mid-2027: please become a partner today to speed up our growth rate and land new features faster.