Export database table as .sql before deleting/removing a plugin
If your plugin overrides onBeforeUninstall(), then you could call craft()-&gt;db-&gt;backup();

But that will backup the whole database via PHP code, which might not be what you want.

Since you're in a plugin, I'd probably make sure mysqldump is available to PHP via the command line and use that to execute it and that way you can also specify the exact tables you'd like to dump.