First of all I would like to point out that you need not meddle with /lib/mysql, or mysqldump if you have a phpmyadmin on both platforms. Moving mysql databases around is really easy and secure just with exporting structure and data as 'sql' and running the whole thing as query in the new place.
Plus there is the great 'JoomlaPack' which is probably what you want to use anyways.
JoomlaPack can backup your entire site including additional databases, etc. and reinstall the whole package using a modified JoomlaInstaller on any other server.
Now in your case the whole thing is a bit more complicated than this because you have content on each server and if I get you right you need to merge the content.
Possible solutions:
1) How much content do you need to merge? If the amount of content on the production server is small, just hand-migrate it to your test environment first, then use JoomlaPack to make a full backup, upload the backup to your production environment and use the JoomlaPack installer to make a fresh install of Joomla including your data and everything!
2) If it is a bit more, you can start with a 'diff' (comparison) of the 'sql' data dumps of both versions then merge that data carefully and proceed as in 1). You can use WinDiff for this or TortoiseDiff if you have TortoiseSVN installed.