Dumper
This class is used to dump and restore a Postgres database.
Version Added
1.0.0
Source code in pum/dumper.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | |
__init__
Initialize the Dumper.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pg_connection
|
str
|
PostgreSQL service name or connection string. Can be a service name (e.g., 'mydb') or a full connection string (e.g., 'postgresql://user:pass@host/db' or 'host=localhost dbname=mydb'). |
required |
dump_path
|
str
|
Path where the dump file will be saved or loaded from. |
required |
Source code in pum/dumper.py
pg_dump
pg_dump(dbname: str | None = None, *, pg_dump_exe: str = 'pg_dump', exclude_schema: list[str] | None = None, format: DumpFormat = DumpFormat.CUSTOM)
Call the pg_dump command to dump a db backup
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dbname
|
str | None
|
Name of the database to dump. |
None
|
pg_dump_exe
|
str
|
Path to the pg_dump executable. |
'pg_dump'
|
exclude_schema
|
list[str] | None
|
List of schemas to exclude from the dump. |
None
|
format
|
DumpFormat
|
DumpFormat, either custom (default) or plain |
CUSTOM
|
Source code in pum/dumper.py
pg_restore
pg_restore(dbname: str | None = None, pg_restore_exe: str = 'pg_restore', exclude_schema: list[str] | None = None)