Documentation
¶
Index ¶
- func EmitLogicalManifest(ctx context.Context, cfg LogicalConfig, records chan<- *connectors.Record) error
- func EmitPhysicalManifest(ctx context.Context, cfg PhysicalConfig, records chan<- *connectors.Record) error
- type ClusterConfig
- type ColumnInfo
- type ConstraintInfo
- type DatabaseInfo
- type Extension
- type IndexInfo
- type LogicalConfig
- type Manifest
- type ManifestOptions
- type PhysicalConfig
- type RelationInfo
- type Role
- type SchemaInfo
- type Tablespace
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EmitLogicalManifest ¶
func EmitLogicalManifest(ctx context.Context, cfg LogicalConfig, records chan<- *connectors.Record) error
EmitLogicalManifest builds the manifest for a logical backup and sends it on records. It connects to the target database (or "postgres" for a full-cluster backup), queries cluster and per-database metadata, and emits /manifest.json.
func EmitPhysicalManifest ¶
func EmitPhysicalManifest(ctx context.Context, cfg PhysicalConfig, records chan<- *connectors.Record) error
EmitPhysicalManifest builds the manifest for a physical backup and sends it on records. It queries full cluster and per-database metadata (the physical backup captures all databases at the file level, so relation detail is still useful for inventory purposes).
Types ¶
type ClusterConfig ¶
type ClusterConfig struct {
DataDirectory string `json:"data_directory,omitempty"`
Timezone string `json:"timezone,omitempty"`
MaxConnections int `json:"max_connections,omitempty"`
WalLevel string `json:"wal_level,omitempty"`
ServerEncoding string `json:"server_encoding,omitempty"`
DataChecksums bool `json:"data_checksums"`
BlockSize int `json:"block_size,omitempty"`
WalBlockSize int `json:"wal_block_size,omitempty"`
LCCollate string `json:"lc_collate,omitempty"`
LCCType string `json:"lc_ctype,omitempty"`
ArchiveMode string `json:"archive_mode,omitempty"`
ArchiveCommandSet bool `json:"archive_command_set"` // true when archive_command is non-empty; the command itself is not stored to avoid leaking credentials
}
ClusterConfig holds key server configuration parameters.
type ColumnInfo ¶
type ColumnInfo struct {
Position int `json:"position"`
Name string `json:"name"`
Type string `json:"type"`
Nullable bool `json:"nullable"`
Default string `json:"default,omitempty"`
}
ColumnInfo describes one column of a relation.
type ConstraintInfo ¶
type ConstraintInfo struct {
Name string `json:"name"`
Type string `json:"type"`
Columns []string `json:"columns,omitempty"`
}
ConstraintInfo describes one constraint on a relation. Type codes: p=primary key, u=unique, f=foreign key, c=check, x=exclusion. Columns lists the constrained column names (empty for check constraints on expressions and for exclusion constraints).
type DatabaseInfo ¶
type DatabaseInfo struct {
Name string `json:"name"`
Owner string `json:"owner"`
Encoding string `json:"encoding"`
Collate string `json:"collate"`
CType string `json:"ctype"`
AllowConn bool `json:"allow_conn"`
IsTemplate bool `json:"is_template"`
DefaultTablespace string `json:"default_tablespace,omitempty"`
ConnectionLimit int `json:"connection_limit"` // -1 = no limit
Extensions []Extension `json:"extensions,omitempty"`
Schemas []SchemaInfo `json:"schemas,omitempty"`
Relations []RelationInfo `json:"relations,omitempty"`
}
DatabaseInfo describes a PostgreSQL database and its contents.
type Extension ¶
type Extension struct {
Name string `json:"name"`
Version string `json:"version"`
Schema string `json:"schema"`
}
Extension describes an installed PostgreSQL extension.
type IndexInfo ¶
type IndexInfo struct {
Name string `json:"name"`
Method string `json:"method"` // btree, hash, gist, gin, brin, …
Definition string `json:"definition"`
IsUnique bool `json:"is_unique"`
IsPrimary bool `json:"is_primary"`
IsValid bool `json:"is_valid"`
IsPartial bool `json:"is_partial"` // has a WHERE predicate
ConstraintName string `json:"constraint_name,omitempty"`
}
IndexInfo describes one index on a relation.
type LogicalConfig ¶
type LogicalConfig struct {
PSQLBin string
PgDumpBin string
Conn pgconn.ConnConfig
Database string // empty = full-cluster backup
DumpFormat string
Options ManifestOptions
}
LogicalConfig holds the parameters needed to build and emit a logical (pg_dump / pg_dumpall) backup manifest.
type Manifest ¶
type Manifest struct {
Version int `json:"version"`
CreatedAt time.Time `json:"created_at"`
Connector string `json:"connector"`
Host string `json:"host"`
Port string `json:"port"`
ServerVersion string `json:"server_version"`
ServerVersionNum int `json:"server_version_num"`
PgDumpVersion string `json:"pg_dump_version,omitempty"`
PgBaseBackupVersion string `json:"pg_basebackup_version,omitempty"`
ClusterSystemIdentifier string `json:"cluster_system_identifier,omitempty"`
InRecovery bool `json:"in_recovery"`
Database string `json:"database,omitempty"`
DumpFormat string `json:"dump_format"`
Options *ManifestOptions `json:"options,omitempty"`
ClusterConfig *ClusterConfig `json:"cluster_config,omitempty"`
Roles []Role `json:"roles,omitempty"`
Tablespaces []Tablespace `json:"tablespaces,omitempty"`
Databases []DatabaseInfo `json:"databases,omitempty"`
}
type ManifestOptions ¶
type PhysicalConfig ¶
type PhysicalConfig struct {
PSQLBin string
PgBaseBackupBin string
Conn pgconn.ConnConfig
}
PhysicalConfig holds the parameters needed to build and emit a physical (pg_basebackup) backup manifest.
type RelationInfo ¶
type RelationInfo struct {
Schema string `json:"schema"`
Name string `json:"name"`
Owner string `json:"owner"`
Persistence string `json:"persistence"` // p=permanent, u=unlogged, t=temp
Kind string `json:"kind"` // see above
Tablespace string `json:"tablespace,omitempty"`
RowEstimate int64 `json:"row_estimate"` // reltuples (fast, may be stale)
LiveRowEstimate int64 `json:"live_row_estimate"` // n_live_tup from autovacuum
ColumnCount int `json:"column_count"`
HasPrimaryKey bool `json:"has_primary_key"`
HasTriggers bool `json:"has_triggers"`
RLSEnabled bool `json:"rls_enabled"`
RLSForced bool `json:"rls_forced"`
IsPartition bool `json:"is_partition"`
PartitionParent string `json:"partition_parent,omitempty"` // "schema.name"
PartitionStrategy string `json:"partition_strategy,omitempty"` // range, list, hash
StorageOptions []string `json:"storage_options,omitempty"` // reloptions
LastVacuum *time.Time `json:"last_vacuum"`
LastAnalyze *time.Time `json:"last_analyze"`
Columns []ColumnInfo `json:"columns,omitempty"`
Constraints []ConstraintInfo `json:"constraints,omitempty"`
Indexes []IndexInfo `json:"indexes,omitempty"`
}
RelationInfo describes any pg_class relation: ordinary table, partitioned table, foreign table, view, materialized view, or sequence. The Kind field uses single-letter relkind codes: r=table, p=partitioned table, f=foreign table, v=view, m=materialized view, S=sequence.
type Role ¶
type Role struct {
Name string `json:"name"`
Superuser bool `json:"superuser"`
Replication bool `json:"replication"`
CanLogin bool `json:"can_login"`
CreateDB bool `json:"create_db"`
CreateRole bool `json:"create_role"`
Inherit bool `json:"inherit"`
BypassRLS bool `json:"bypass_rls"`
ConnectionLimit int `json:"connection_limit"` // -1 = no limit
ValidUntil *time.Time `json:"valid_until"`
MemberOf []string `json:"member_of,omitempty"`
}
Role describes a PostgreSQL role and its group memberships.
type SchemaInfo ¶
SchemaInfo describes one schema within a database.