Database restore loses data when a row is larger than max_allowed_packet

Open
#245 0 comments 0 reactions 0 assignees View on GitHub

@rafaelmaeuer is already working on this.

Since Oct 29, 2026.

  • #249 by @rafaelmaeuer — open

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
25/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
mariadb, mysql, php
Domain
backend, database

Research direction

The issue identifies the database dump and import code but names no files or tests. Start by tracing where dump rows are batched and where restore statements are executed, then inspect the open pull request for the proposed approach. Done means large rows are isolated, oversized statements are split during restore, and a lost connection stops the restore with a clear message.

Written by the indexing model from the issue text.

Description

Describe the bug
Restoring a backup with large rows fails in the database step. BackWPup's dump batches rows into multi-row INSERTs and only starts a new one after the statement is already over 50000 characters, so a statement can take several multi-megabyte rows. When such a statement exceeds the database server's max_allowed_packet, the server drops the connection and data is lost.

To Reproduce

  1. Use a site with a large option row, e.g. All-In-One WP Security's aiowps_plugin_checksums (about 16 MB with ~40 plugins).
  2. Use a database server with the default max_allowed_packet of 16 MB (MariaDB/MySQL default).
  3. Create a backup including the database and restore it.

Observed
Database server log:

[Warning] Aborted connection ... (Got a packet bigger than 'max_allowed_packet' bytes)

With a direct mysqli connection, the restore log then contains hundreds of MySQL server has gone away errors and ends with ... SET FOREIGN_KEY_CHECKS = 1; everything after the failing statement is missing. In the reported case one INSERT INTO wp_options was about 18 MB (a 1.4 MB and a 16.7 MB row plus 50 small rows).

Expected behavior
Large rows are written into their own statement by the backup, oversized statements are split on restore, and a lost connection stops the restore with a clear message.

System

  • BackWPup 5.7.8 (same dump/import code as 4.x)
  • PHP 8.3, MariaDB with default max_allowed_packet (16 MB)

A fix is ready as a pull request.

Dominant language
PHP
Stars
96
Forks
48
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from wp-media/backwpup

All issues in wp-media/backwpup

Similar issues

More PHP issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.