Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

257
Vistas
Automated data dumps from postgres database into .sql using django/python and celery

I'm trying to automate regular data dumps from my postgres database using django/python. I'm using celery to automate it as a task since I want the data dumps to run regularly - every day or every two days. Currently i'm using sh, here's my code:

from sh import pg_dump

@periodic_task(
    run_every=(crontab(minute='*/2')), #set to 2 min interval for testing
    name="portal_backup",
    ignore_result=True)


def portal_backup():
    filename = "portal_backup.sql"
    with gzip.open(filename) as f:
        pg_dump('-U', 'postgres', '-W', '-F', 'p', 'Portal', _out=f)
    print("backup done")

All of my database information is in my .env file , however when I run my code I get this error:

**sh.ErrorReturnCode_1: 
  RAN: /usr/bin/pg_dump -U postgres -W -F p Portal
  STDOUT:
  STDERR:
Password: 
pg_dump: error: connection to database "Portal" failed: FATAL:  Peer authentication failed for user "postgres"**

I don't know why the authentication failed. If anyone has an better ideas on how I can automate this process through django/python and celery any info would be appreciated.

over 4 years ago · Santiago Trujillo
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda