MySQL ? PDO ?
Either way, in general, you loop thru all one you wish to copy/update using a WHILE loop.
In that loop, you have to check the second database for the same data. Assuming the xf_user is unique, you would run a second query to see if that user exists. If it exist, then you update the data. If it does not exist, you insert the data. Not too complex.
One further comment, if you have an last_updated_field in the DB that gets updated when the user changes their personal data, you would not want to update it if the first data is older than the second one.
Hope these comments make sense to you. Backup both of your databases, create the code, show us the code without any passwords or DB access info and then you can test it. Good luck !
( PS: I suggest PDO as it is less hack-able! )