Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

256
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda