Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

255
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!