wp-db-backup can't handle large databases [patch]
|Reported by:||ringmaster||Owned by:||skippy|
|Plugin:||wp-db-backup||Keywords:||backup gzip large database|
Depending on the size of the database, wp-db-backup can't hold all of the information in the database inside a single string. In this case, it runs out of memory, reporting an unfriendly error and not backing up anything.
The attached patch switches the SQL output to write directly to the backup file, rather than first aggregating the SQL statements into a string and then writing to the file.
I could not determine a way to gzip a file without first loading it into memory, so the patch detects whether the raw backup script is too large to contain in memory and if so, it reports a friendlier error with advice to turn off gzip handling.
An improvement beyond this patch would allow the system to gzip directly from disk regardless of the backup file size, or perhaps break the backup into pieces and tar them, or perhaps use gzip output buffering to transfer the raw data, which could then be archived on the downloading client.
Also added in this patch are a few label tags that were missing and driving me nuts.