MCPcopy Create free account
hub / github.com/Dispatcharr/Dispatcharr / _dump_postgresql

Function _dump_postgresql

apps/backups/services.py:74–97  ·  view source on GitHub ↗

Dump PostgreSQL database using pg_dump.

(output_file: Path)

Source from the content-addressed store, hash-verified

72
73
74def _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
100def _clean_postgresql_schema() -> None:

Callers 1

create_backupFunction · 0.85

Calls 3

_get_pg_argsFunction · 0.85
_get_pg_envFunction · 0.85
runMethod · 0.80

Tested by

no test coverage detected