pgrestore

package
v0.2.7 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2025 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DataSectionSettings added in v0.2.6

type DataSectionSettings struct {
	ExitOnError                      bool
	UsePgzip                         bool
	BatchSize                        int64
	OnConflictDoNothing              bool
	OverridingSystemValue            bool
	DisableTriggers                  bool
	SuperUser                        string
	UseSessionReplicationRoleReplica bool
}

DataSectionSettings - settings for data section that changes behavior of dumpers

type Options

type Options struct {
	// Custom
	DirPath string

	// General options:
	DbName   string `mapstructure:"dbname"`
	FileName string `mapstructure:"file"` // --file=FILENAME
	Format   string // Supports only directory format
	List     bool   `mapstructure:"list"`
	Verbose  bool   `mapstructure:"verbose"`
	Version  bool   `mapstructure:"version"`

	// Options controlling the output content
	DataOnly                   bool     `mapstructure:"data-only"`
	Clean                      bool     `mapstructure:"clean"`
	Create                     bool     `mapstructure:"create"`
	ExitOnError                bool     `mapstructure:"exit-on-error"`
	Index                      []string `mapstructure:"index"`
	Jobs                       int      `mapstructure:"jobs"`
	UseList                    string   `mapstructure:"use-list"`
	ListFormat                 string   `mapstructure:"list-format"`
	Schema                     []string `mapstructure:"schema"`
	ExcludeSchema              []string `mapstructure:"exclude-schema"`
	NoOwner                    bool     `mapstructure:"no-owner"`
	Function                   []string `mapstructure:"function"`
	SchemaOnly                 bool     `mapstructure:"schema-only"`
	SuperUser                  string   `mapstructure:"superuser"`
	Table                      []string `mapstructure:"table"`
	Trigger                    []string `mapstructure:"trigger"`
	NoPrivileges               bool     `mapstructure:"no-privileges"`
	SingleTransaction          bool     `mapstructure:"single-transaction"`
	DisableTriggers            bool     `mapstructure:"disable-triggers"`
	EnableRowSecurity          bool     `mapstructure:"enable-row-security"`
	IfExists                   bool     `mapstructure:"if-exists"`
	NoComments                 bool     `mapstructure:"no-comments"`
	NoDataForFailedTables      bool     `mapstructure:"no-data-for-failed-tables"`
	NoPublications             bool     `mapstructure:"no-publications"`
	NoSecurityLabels           bool     `mapstructure:"no-security-labels"`
	NoSubscriptions            bool     `mapstructure:"no-subscriptions"`
	NoTableAccessMethod        bool     `mapstructure:"no-table-access-method"`
	NoTableSpaces              bool     `mapstructure:"no-tablespaces"`
	Section                    string   `mapstructure:"section"`
	StrictNames                bool     `mapstructure:"strict-names"`
	UseSetSessionAuthorization bool     `mapstructure:"use-set-session-authorization"`

	// Custom options (not from pg_restore)
	// OnConflictDoNothing and Inserts were moved from pg_dump because we can generate insert
	// statements on fly if needed
	OnConflictDoNothing bool `mapstructure:"on-conflict-do-nothing"`
	Inserts             bool `mapstructure:"inserts"`
	RestoreInOrder      bool `mapstructure:"restore-in-order"`
	// OverridingSystemValue is a custom option that allows to use OVERRIDING SYSTEM VALUE for INSERTs
	OverridingSystemValue bool `mapstructure:"overriding-system-value"`
	// Use pgzip decompression instead of gzip
	Pgzip                            bool  `mapstructure:"pgzip"`
	BatchSize                        int64 `mapstructure:"batch-size"`
	UseSessionReplicationRoleReplica bool  `mapstructure:"use-session-replication-role-replica"`

	// Connection options:
	Host       string `mapstructure:"host"`
	Port       int    `mapstructure:"port"`
	UserName   string `mapstructure:"username"`
	NoPassword bool   `mapstructure:"no-password"`
	Password   bool   `mapstructure:"password"`
	Role       string `mapstructure:"role"`
}

func (*Options) GetParams

func (o *Options) GetParams() []string

func (*Options) GetPgDSN

func (o *Options) GetPgDSN() (string, error)

func (*Options) ToDataSectionSettings added in v0.2.6

func (o *Options) ToDataSectionSettings() *DataSectionSettings

type PgRestore

type PgRestore struct {
	BinPath string
}

func NewPgRestore

func NewPgRestore(binPath string) *PgRestore

func (*PgRestore) Run

func (pr *PgRestore) Run(ctx context.Context, options *Options) error

type Script

type Script struct {
	Name      string   `mapstructure:"name"`
	When      string   `mapstructure:"when"`
	Query     string   `mapstructure:"query"`
	QueryFile string   `mapstructure:"query_file"`
	Command   []string `mapstructure:"command"`
}

func (*Script) Execute

func (s *Script) Execute(ctx context.Context, tx pgx.Tx) error

func (*Script) ExecuteCommand

func (s *Script) ExecuteCommand(ctx context.Context) error

func (*Script) ExecuteQuery

func (s *Script) ExecuteQuery(ctx context.Context, tx pgx.Tx) error

func (*Script) ExecuteQueryFile

func (s *Script) ExecuteQueryFile(ctx context.Context, tx pgx.Tx) error

Jump to

Keyboard shortcuts

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