masquerade icon indicating copy to clipboard operation
masquerade copied to clipboard

Run masquerade against a .sql file instead of database

Open alexhert opened this issue 2 years ago • 4 comments

is it possible to run this agains an mysqldump ? it would be great to masquerade an existing mysql backup instead of changing data on database itself.

alexhert avatar Jul 18 '22 20:07 alexhert

I agree but I have no clue how to make that happen.

peterjaap avatar Jul 19 '22 05:07 peterjaap

Another approach could be made possible using https://github.com/ifsnop/mysqldump-php. Another lib https://github.com/heyday/laravel-anonymised-sql-dumps uses it.

toonvd avatar Aug 18 '22 13:08 toonvd

@toonvd that looks interesting. But that will mean a very big rewrite since we now generate queries and run them against MySQL https://github.com/elgentos/masquerade/blob/39baae746b12bba869fe582ea6b322fbbdef1da4/src/Elgentos/Masquerade/DataProcessor/TableService.php#L355

If we were to use mysqldump-php, we'll have to rewrite everything to transform callables like this https://github.com/ifsnop/mysqldump-php#changing-values-when-exporting

Doable, but a lot of work. Not sure if it's worth the hassle.

peterjaap avatar Aug 18 '22 13:08 peterjaap

It depends on your requirements indeed, for me, a stream using an anonymous mysqldump would mean a lot less i/o when migrating DBs. Also, it avoids anonimising the wrong (production) DB by mistake. I guess this could be a separate project.

toonvd avatar Aug 18 '22 14:08 toonvd