diff --git a/services/backup-daemon/docker/granular/pg_backup.py b/services/backup-daemon/docker/granular/pg_backup.py index 184b4e64..68afc93a 100644 --- a/services/backup-daemon/docker/granular/pg_backup.py +++ b/services/backup-daemon/docker/granular/pg_backup.py @@ -498,8 +498,7 @@ def fetch_roles(self, database): output, type(output), exit_code ) ) - # grep exits 1 when no lines match, which is valid (no owner roles found) - if exit_code not in (0, 1): + if exit_code != 0: stderr.seek(0) raise backups.BackupFailedException( database, "\n".join(stderr.readlines()) @@ -541,12 +540,14 @@ def dump_roles_for_db(self, roles, database): ) ) cmd = cmd + encrypt_cmd - p = Popen(cmd, shell=True, stdout=dump, stderr=stderr) + proc_env = os.environ.copy() + proc_env["PGPASSWORD"] = configs.postgres_password() or "" + p = Popen(cmd, shell=True, stdout=dump, stderr=stderr, env=proc_env) output, err = p.communicate() self.log.debug("Fetch roles command: {}".format(cmd)) exit_code = p.returncode - # grep exits 1 when no lines match, which is valid (no roles to dump) - if exit_code not in (0, 1): + + if exit_code != 0: stderr.seek(0) raise backups.BackupFailedException( database, "\n".join(stderr.readlines())