title: how to backup a django db
body: <p>I have a Django application that uses a Postgres database.  I need to be able to backup and restore the db, both to ensure no data is lost and to be able to copy data from the production server to the development server during testing.</p>
  
  <p>There seem to be a few different ways to do this:</p>
  
  <ol>
  <li><p>Just interact with the db directly.  So, for Postgres I might write a script using <code>pg_dumpall</code> and <code>psql</code>.</p></li>
  <li><p>Use the <code>sqlclear</code>/<code>sqlall</code> commands that come with Django.</p></li>
  <li><p>Use the <code>dumpdata</code>/<code>loaddata</code> commands that come with Django.  So create new fixtures from the db you want to backup and then load them into the db you want to restore.</p></li>
  <li><p>Use a Django plugin like <a href="https://pypi.python.org/pypi/django-dbbackup" rel="noreferrer">django-dbbackup</a>.</p></li>
  </ol>
  
  <p>I really don't understand the pros/cons of these different techniques.  </p>
  
  <p>Just off the top of my head: Option 1 is database-specific and option 3 seems more suited to setting up initial data.  But I'm still not sure what advantages option 4 has over option 2.</p>