Silent restore failure on large databases — PHP execution time limit
0 reputation · 25 Feb 2021, 00:48 UTC
0 reputation · 25 Feb 2021, 00:48 UTC
Magento's built-in backup tool creates database archives that can exceed practical PHP execution limits during restoration. The bin/magento setup:backup --restore command and admin UI restoration process do not surface a timeout error when the PHP max_execution_time is reached; the operation appears to complete while leaving the database in a partially restored state.
No automated checksum or integrity verification runs after restore, so merchants must manually compare table row counts, foreign key constraints, and media file counts against pre-backup records. This gap is compounded when restoring to a different Magento version or with mismatched extensions, where schema mismatches require additional setup:upgrade runs that may themselves time out.
CHECKSUM TABLE comparisons?34775 reputation · 25 Feb 2021, 02:10 UTC
The Magento backup/restore utility runs inside a PHP process. When the archive is large, the PHP runtime can hit max_execution_time (or a proxy‑level timeout). The process stops immediately, but any SQL statements that have already been committed remain in the database. Because the Magento CLI does not roll back on timeout, the command exits with a success exit code, giving the illusion that the restore finished.
php -r "echo ini_get('max_execution_time');" on the server where the restore is executed. A value other than 0 indicates a hard limit that may be reached during a large import.
error.log for entries such as Aborted connection or Got a packet bigger than max_allowed_packet. A connection close that occurs before the dump ends signals a premature stop.
SELECT table_name, data_length, index_length FROM information_schema.tables WHERE table_schema='your_db';
After restore, run the same query and look for missing tables or reduced sizes.
mysql -u user -p dbname < dump.sql. The MySQL client is not subject to PHP execution limits and will abort only on a real database error.
setup:upgrade only after a complete restore. A partial restore can leave the schema in an inconsistent state; verify table counts before upgrading.
Instead of manual CHECKSUM TABLE runs, you can automate a lightweight verification step:
SELECT SUM(data_length + index_length) AS total_bytes FROM information_schema.tables WHERE table_schema='your_db';
Save the value.
This method is fast, requires no extra tools, and works for any Magento version or set of extensions.
Does the restore run via the Magento CLI or through the admin UI?
If it is the admin UI, additional web server timeouts (Apache, Nginx, or a reverse proxy) may be the root cause, and increasing max_execution_time alone will not help. In that case, the native MySQL import remains the safest path.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.