Dump PostgreSQL database using pg_dump.
(output_file: Path)
| 72 | |
| 73 | |
| 74 | def _dump_postgresql(output_file: Path) -> None: |
| 75 | """Dump PostgreSQL database using pg_dump.""" |
| 76 | logger.info("Dumping PostgreSQL database with pg_dump...") |
| 77 | |
| 78 | cmd = [ |
| 79 | "pg_dump", |
| 80 | *_get_pg_args(), |
| 81 | "-Fc", # Custom format for pg_restore |
| 82 | "-v", # Verbose |
| 83 | "-f", str(output_file), |
| 84 | ] |
| 85 | |
| 86 | result = subprocess.run( |
| 87 | cmd, |
| 88 | env=_get_pg_env(), |
| 89 | capture_output=True, |
| 90 | text=True, |
| 91 | ) |
| 92 | |
| 93 | if result.returncode != 0: |
| 94 | logger.error(f"pg_dump failed: {result.stderr}") |
| 95 | raise RuntimeError(f"pg_dump failed: {result.stderr}") |
| 96 | |
| 97 | logger.debug(f"pg_dump output: {result.stderr}") |
| 98 | |
| 99 | |
| 100 | def _clean_postgresql_schema() -> None: |
no test coverage detected