title: Postgres: clear entire database before re-creating / re-populating from bash script
body: <p>I'm writing a shell script (will become a cronjob) that will:</p>
  
  <p>1: dump my production database</p>
  
  <p>2: import the dump into my development database</p>
  
  <p>Between step 1 and 2, I need to clear the development database (drop all tables?). How is this best accomplished from a shell script? So far, it looks like this:</p>
  
  <pre><code>#!/bin/bash
  time=`date '+%Y'-'%m'-'%d'`
  # 1. export(dump) the current production database
  pg_dump -U production_db_name &gt; /backup/dir/backup-${time}.sql
  
  # missing step: drop all tables from development database so it can be re-populated
  
  # 2. load the backup into the development database
  psql -U development_db_name &lt; backup/dir/backup-${time}.sql
  </code></pre>