Converting Postgresql data to Open Street Maps
You can do that with osmosis, this is an example to export from postgis to osm:
osmosis --read-apidb host="x" database="x" user="x" password="x" --write-xml file="planet.osm"
Here is an osmosis setup HowTo