pgdumprestore

package
v1.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 10, 2026 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	SourcePGURL    string
	TargetPGURL    string
	CleanTargetDB  bool
	CreateTargetDB bool
	// if set to true the snapshot will include all database objects, not tied
	// to any particular schema, such as extensions or triggers.
	IncludeGlobalDBObjects bool
	// Role name to be used to create the dump
	Role string
	// "enabled", "disabled", or "no_passwords"
	RolesSnapshotMode string
	// Do not output commands to set ownership of objects to match the original
	// database.
	NoOwner bool
	// Prevent dumping of access privileges (grant/revoke commands)
	NoPrivileges bool
	// if set, the dump will be written to this file for debugging purposes
	DumpDebugFile string
	// if set, security label providers that will be excluded from the dump
	ExcludedSecurityLabels []string
	// if set to true, materialized views will be refreshed (REFRESH MATERIALIZED
	// VIEW ... WITH DATA) after the table data has been restored. Disabled by
	// default since refreshing can be expensive on large views.
	RefreshMaterializedViews bool
	// Session settings in name=value format applied only while restoring indexes
	// and constraints. An empty list preserves the existing behavior.
	IndexConstraintSessionSettings []string
	// IndexRestoreRetries is the retry policy applied when restoring indexes
	// and constraints fails with a transient error. If not set, it defaults to
	// exponential backoff with an initial interval of 1s, a max interval of
	// 1min and 3 retries.
	IndexRestoreRetries backoff.Config
	// IndexRestoreWorkers is the number of standalone CREATE INDEX/CREATE
	// UNIQUE INDEX statements restored concurrently against the target
	// database. Statements that depend on an index existing (constraints
	// added USING INDEX, comments, partition attachments, REPLICA IDENTITY
	// and CLUSTER) are always restored afterwards, once every index has been
	// created. Defaults to 1, which preserves the existing sequential
	// behaviour. Each worker holds a target connection and applies
	// IndexConstraintSessionSettings to it, so both the connections and the
	// memory those settings reserve scale with this value. Capped at
	// maxIndexRestoreWorkers.
	IndexRestoreWorkers uint
	// IncludeObjectTypes is a list of object type categories to include in the
	// schema snapshot. Only one of IncludeObjectTypes or ExcludeObjectTypes
	// can be set.
	IncludeObjectTypes []string
	// ExcludeObjectTypes is a list of object type categories to exclude from
	// the schema snapshot. Only one of IncludeObjectTypes or
	// ExcludeObjectTypes can be set.
	ExcludeObjectTypes []string
}

type Option

type Option func(s *SnapshotGenerator)

func WithInstrumentation added in v0.6.0

func WithInstrumentation(i *otel.Instrumentation) Option

func WithLogger

func WithLogger(logger loglib.Logger) Option

func WithProgressTracking added in v0.9.0

func WithProgressTracking(ctx context.Context) Option

func WithRestoreConflictTargetsBeforeData added in v1.1.0

func WithRestoreConflictTargetsBeforeData() Option

WithRestoreConflictTargetsBeforeData restores constraints and indexes that can be used as INSERT ... ON CONFLICT targets (primary keys, unique constraints and unique indexes) before the wrapped data snapshot generator runs. This is required when the data writer emits INSERT ... ON CONFLICT DO UPDATE, since the target table must already have a matching unique or primary key constraint at insert time.

func WithRestoreToWAL added in v1.0.0

func WithRestoreToWAL(processor processor.Processor) Option

func WithSnapshotGenerator added in v0.6.0

func WithSnapshotGenerator(g generator.SnapshotGenerator) Option

type PGSnapshotWALRestore added in v1.0.0

type PGSnapshotWALRestore struct {
	// contains filtered or unexported fields
}

PGSnapshotWALRestore handles restoring a pg_dump snapshot as WAL DDL events

type SnapshotGenerator

type SnapshotGenerator struct {
	// contains filtered or unexported fields
}

SnapshotGenerator generates postgres schema snapshots using pg_dump and pg_restore

func NewSnapshotGenerator

func NewSnapshotGenerator(ctx context.Context, c *Config, opts ...Option) (*SnapshotGenerator, error)

NewSnapshotGenerator will return a postgres schema snapshot generator that uses pg_dump and pg_restore to sync the schema of two postgres databases

func (*SnapshotGenerator) Close

func (s *SnapshotGenerator) Close() error

func (*SnapshotGenerator) CreateSnapshot

func (s *SnapshotGenerator) CreateSnapshot(ctx context.Context, ss *snapshot.Snapshot) (err error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL