1

I created a backup script for automatically take backup od the database. the code executes and works fine. but, at the end of the execution, it shows a broken pipe error.

import gzip
import subprocess

with gzip.open('backup.gz', 'wb') as f:
    popen = subprocess.Popen(['pg_dump', '--no-owner', '--no-acl', '-U', 'postgres', '-d', 'esell_db', '-h', '127.0.0.1'], stdout=subprocess.PIPE, stdin=subprocess.PIPE, universal_newlines=True)
popen.stdin.write("rootVidhyaDhan123#!\n")
    for stdout_line in iter(popen.stdout.readline, ""):
        f.write(stdout_line.encode('utf-8'))
    popen.stdin.close()
    popen.stdout.close()
    popen.wait()
Jinto Antony
  • 458
  • 8
  • 26

0 Answers0