In oder to export everything correctly you must have knowledge of the database schema.
The following is an example query to export contacts including custom fields to a csv file.
select * from contacts inner join contacts_cstm on contacts.id = contacts_cstm.id_c INTO OUTFILE 'c:/contacts.csv' FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\n';
This method has some drawbacks:
. the query doesn’t add the headers so you have to do it manaully or through another query
. if the output file (in my example it is: contacts.csv) already exists you will get an error so make sure you delete it before executing the query
. my example query only considers the table contacts and contacts_cstm (custom fields) but it doesn’t take into account other information such as email addresses, which are stored in a different table and other information related into other tables
. to make it complete you will have to work out a more complex query, given the complexity of the database I don’t think it will be easy in one single query
Additional info
In order to be able to run this query I have had to comment out by prepending a semi-colon the line with secure_file_priv= in my.ini
Comment:
It will be probably easier if you write a php script that loops through the database and collects all information from the necessary tables and then appends to a csv file. It will be quite long to execute but you can do it in different runs