Skip to content

fix: Use mysqldump for large database exports v1.4.9

Choose a tag to compare

@danbaileyza danbaileyza released this 26 Feb 14:09
· 3 commits to main since this release
Critical Problem:
- Database export timing out silently on very large databases
- Web server killing PHP process before completion
- Backups never finish, always show 'attempt 1/3'
- Failure counter can't increment (no exception thrown)
- Infinite loop of failed backup attempts

Root Cause:
- PHP export too slow for multi-GB databases
- Web server timeout kills process silently
- No error thrown, just silent death
- Lock released, backup retries from scratch

Solution - Use mysqldump:
- Try mysqldump first (native MySQL tool)
- 10-100x faster than PHP export
- No memory or time limits
- Falls back to PHP if unavailable

mysqldump Implementation:
- Search common paths for mysqldump binary
- Build command with proper escaping
- Use --single-transaction for consistency
- Use --quick for memory efficiency
- Use --lock-tables=false to avoid locks
- Handle host:port format correctly
- Log success/failure with file size and time

Failure Counter Fix:
- Re-read failure count in catch block (scope issue)
- Properly increment and save to transient
- Now shows correct attempt numbers
- Will stop after 3 failures

Benefits:
- Can handle databases of ANY size
- Multi-GB databases export in minutes
- No more silent timeouts
- Proper failure tracking
- Automatic fallback to PHP if needed

Testing:
- Will try mysqldump first
- Log which method is used
- Show export time and file size
- Fall back gracefully if mysqldump unavailable