The geofield module creates a blob field in the database and inserts binary data into the field. When dumping this data with backup_migrate the resulting file becomes very hard to import because some of the data is invalid. phpMyAdmin, for instance, offers to write binary data in hexadecimal format, which makes it easier to import.

I'd like to propose this for backup_migrate as well. I will add a patch shortly to demonstrate my idea.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Jorrit created an issue. See original summary.

Jorrit’s picture

Before:

binary data

After:

0x0101000000122cb3ad0b241340794ec46c13ca4940

I noticed that destinations.db.mysql.inc and sources.db.mysql.inc have some duplicated code. I only changed sources.db.mysql.inc in the patch. If the solution is acceptable, I will copy the changes to destinations.db.mysql.inc and upload a new patch

The solution also changes how integers are written: when possible, they will not be surrounded with quotes.

Before:

'node','oa_event','0','568','632','und','0','1506668400','1506672000'

After:

'node','oa_event',0,568,632,'und',0,1506668400,1506672000

If you don't like that, I can remove it. The most important part is the binary data encoding.

Jorrit’s picture

FileSize
1.67 KB

A better example of what the SQL looks like before this patch.

Jorrit’s picture

Status: Active » Needs review
RAFA3L’s picture

Thanks Jorrit, I notice this problem with geofield just yesterday importing into another server and discover that Sequel Pro export in hexadecimal too, phpMyAdmin is not good for import/export large databases. For example with this big database when I press GO to export in phpMyadmin download the html of the export page. I'll try the patch.

Leeteq’s picture

Priority: Normal » Major
DamienMcKenna’s picture

Status: Needs review » Needs work

This needs some slight cleaning up to match the Drupal coding standards and comments explaining what's going on. Thanks.

Jorrit’s picture

Done. Thanks for your attention.

wombatman’s picture

Thank you for this. Geofield data was being incorrectly encoded by Backup and Migrate dump which was corrupting database when restored using MySQL Workbench. Applied the patch and all looks to be working again.

Jorrit’s picture

Status: Needs review » Reviewed & tested by the community

Thanks for confirming!

DamienMcKenna’s picture

Rerunning the tests to make sure the patch still works..

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 8: 2916783-backup_migrate-encode-binary-data-8.patch, failed testing. View results

Jorrit’s picture

DamienMcKenna’s picture

Have you tested restoring an existing backup after this patch is applied?