title: postgres database backup with corrupted tables
body: <p>We have Odoo 8 running on Digital Ocean and would like to move database to local intranet. For that I setup Odoo 8 on local machine. </p>
  
  <p>I wanted to export the database, but I am failing to export from Postgres to mounted Drive, I'm facing following error whenever I try to export</p>
  
  <pre class="lang-none prettyprint-override"><code>pg_dump mydatabasetoday &gt; /mnt/volume-fra1-01/db_backup/lakes2.sql
  
  
  Error:
  pg_dump: Dumping the contents of table "mail_message" failed: PQgetResult() failed.
  pg_dump: Error message from server: ERROR:  missing chunk number 0 for toast value 148458 in pg_toast_18366
  pg_dump: The command was: COPY public.mail_message (id, create_date, write_date, mail_server_id, write_uid, subject, create_uid, parent_id, subtype_id, res_id, message_id, body, model, record_name, no_auto_thread, date, author_id, type, reply_to, email_from, link_ebf, guid, type_email) TO stdout;
  </code></pre>
  
  <p>I have tried to <code>reindex</code>, but unable to export to .sql to restore from another Server</p>
  
  <p>I just need a database export thats all.</p>
  
  <p><strong>Steps we done so far.</strong></p>
  
  <ol>
  <li>Command to Copy from mydatabase to CSV format</li>
  </ol>
  
  
  
  <pre><code>COPY ( select id, create_date, write_date, mail_server_id, write_uid,  create_uid, parent_id, subtype_id, res_id, message_id,body, record_name, no_auto_thread, date, model, reply_to, author_id,  email_from  from mail_message    ) TO '/tmp/sb_mail_message.csv' DELIMITER ',';
  </code></pre>
  
  <p>Unable to Import.</p>
  
  <ol start="2">
  <li><p>Downloaded CSV sample format of all corrupted table of <code>mail_messages</code> from PGADMIN 4.1. But its not in correct format to import.</p></li>
  <li><p>Ran script to encode export message to CSV format and tried to import, but unable to work around properly give me following error</p></li>
  </ol>
  
  <pre class="lang-none prettyprint-override"><code>INTERNAL SERVER ERROR
  500 Internal Server Error
  Internal Server Error
  The server encountered an internal error and was unable to complete your request.  Either the server is overloaded or there is an error in the application
  </code></pre>
  
  <p>I would like to know if there any possibility to take backup of corrupted table</p>
  
  <ol>
  <li><p>To take complete Snapshot of Postgres database snapshot and restore location</p></li>
  <li><p>Replication of database from live Postgres to local Postgres.</p></li>
  </ol>