title: postgresql how to backup and overwrite specific tables
body: <p>I need to be able to somehow get a set of tables from my dev db into my production db. I've just been creating a dump file from the dev db and using pg_restore on the production db. The problem now is that I need to preserve one table(called users) on the production db while replacing the others</p>
  
  <p>I think I have the dump properly from this command</p>
  
  <pre><code>pg_dump -Fc --no-acl --no-owner -h localhost -U &lt;USER&gt; --exclude-table=users* --data-only &lt;DB NAME&gt; &gt; test.dump
  </code></pre>
  
  <p>But I can't get the restore part to work. I tried the following command</p>
  
  <pre><code>pg_restore -Fc --no-acl --no-owner -h &lt;PROD HOST&gt; -U &lt;USER&gt; -d &lt;DB NAME&gt; -p &lt;PORT&gt; &lt;FILE LOCATION&gt;
  </code></pre>
  
  <p>BUt I get the following errors</p>
  
  <pre><code>pg_restore: [archiver (db)] Error while PROCESSING TOC:
  pg_restore: [archiver (db)] Error from TOC entry 2009; 0 121384 TABLE DATA idx_descs Jason
  pg_restore: [archiver (db)] COPY failed for table "idx_descs": ERROR:  duplicate key value violates unique constraint "idx_descs_pkey"
  DETAIL:  Key (id)=(6) already exists.
  CONTEXT:  COPY idx_descs, line 1
  </code></pre>
  
  <p>It seems like for the tables I'm trying to overwrite, it is just trying to append the data and running into trouble because there are now duplicate primary keys. Any Ideas how to do this? Thanks</p>