title: Archiving records from PostgreSQL database that surpass timeline
body: <p>Let's say we have a database for a bus company.</p>
  
  <ul>
  <li>We collect data about bus rides, passenger lists, fuel etc.</li>
  <li>We mostly work with data about upcoming rides</li>
  <li>Sometimes we need to look in the history (for accounting), but the time frame is short (3 months at max). </li>
  <li>We don't want to keep all the records on our production/development servers for obvious reasons (storage waste, slow queries etc.). </li>
  <li>We want to have separate database where we would archive whole history.</li>
  <li>What would be the best way to achieve this on PostgreSQL?</li>
  </ul>
  
  <p>We're looking for something like this:</p>
  
  <ul>
  <li>We want to replicate production database (including structure changes, sequences etc.)</li>
  <li>We want to delete old data from production database, but exclude these statements from the replication to keep archive untouched.</li>
  </ul>
  
  <p>Example:</p>
  
  <ul>
  <li>When a bus trip is older than 3 months, delete it from production DB, but keep it in the archive DB, where it already is.</li>
  </ul>
  
  <p>What we are currently looking into:</p>
  
  <ul>
  <li>Some kind of Master/Slave replication (Slony?).</li>
  <li>ENABLE REPLICA RULE for specific tables where we amend DELETE/UPDATE statements with some time rules (WHERE date &lt; NOW() - interval '6 months')</li>
  </ul>
  
  <p>Thanks for your insights.</p>