subprocess.run only fails loudly with check=True
subprocess.run returns a result object whether the command worked or not, so a rejected git push or a pg_dump that wrote nothing leaves no exception behind. The script moves to the next line and finishes as a success.
subprocess.run(["pg_dump", "-Fc", db, "-f", path], check=True)check=True raises CalledProcessError on any non-zero exit. Pass capture_output=True, text=True as well and the exception carries returncode and stderr, which is the part you need in the traceback.
python