def export_db(filename=None, remote=False):
    """
    Exports the database.

    Make sure that you have this in your ``~/.pgpass`` file:

    localhost:5433:*:<db_role>:<password>

    Also make sure that the file has ``chmod 0600 .pgpass``.

    Usage::

        fab export_db
        fab export_db:filename=foobar.dump

    """
    local_machine()
    if not filename:
        filename = settings.DB_DUMP_FILENAME
    if remote:
        backup_dir = settings.FAB_SETTING('SERVER_DB_BACKUP_DIR')
    else:
        backup_dir = ''

    local('pg_dump -c -Fc -O -U {0}{1} {2} -f {3}{4}'.format(
        env.db_role, HOST, env.db_name, backup_dir, filename))
Exports the database.

    Make sure that you have this in your ``~/.pgpass`` file:

    localhost:5433:*:<db_role>:<password>

    Also make sure that the file has ``chmod 0600 .pgpass``.

    Usage::

        fab export_db
        fab export_db:filename=foobar.dump