Documentation ¶
Index ¶
- Constants
- Variables
- func ApplyFileIncrement(fileName string, increment io.Reader) error
- func Configure() (*TarUploader, *S3Prefix, error)
- func Connect() (*pgx.Conn, error)
- func CreateUploader(svc s3iface.S3API, partsize, concurrency int) s3manageriface.UploaderAPI
- func DownloadAndDecompressWALFile(pre *S3Prefix, walFileName string, dstLocation string) error
- func ExtractAll(tarInterpreter TarInterpreter, files []ReaderMaker) error
- func FormatName(s string) (string, error)
- func GetBackupPath(prefix *S3Prefix) *string
- func GetFileExtension(path string) string
- func GetKeyRingId() string
- func GetSentinelUserData() interface{}
- func HandleBackupFetch(backupName string, pre *S3Prefix, dirArc string, mem bool) (lsn *uint64)
- func HandleBackupList(pre *S3Prefix)
- func HandleBackupPush(dirArc string, tu *TarUploader, pre *S3Prefix)
- func HandleDelete(pre *S3Prefix, args []string)
- func HandleTar(bundle TarBundle, path string, info os.FileInfo, crypter Crypter) error
- func HandleWALFetch(pre *S3Prefix, walFileName string, location string, triggerPrefetch bool)
- func HandleWALPrefetch(pre *S3Prefix, walFileName string, location string)
- func HandleWALPush(tarUploader *TarUploader, dirArc string, pre *S3Prefix, verify bool)
- func IsPagedFile(info os.FileInfo, fileName string) bool
- func MoveFileAndCreateDirs(incrementalPath string, targetPath string, fileName string) (err error)
- func NewDiskLimitReader(r io.ReadCloser) io.ReadCloser
- func NewLzoReader(r io.Reader) (io.ReadCloser, error)
- func NewLzoWriter(w io.Writer) io.WriteCloser
- func NewNetworkLimitReader(r io.ReadCloser) io.ReadCloser
- func NextWALFileName(name string) (nextname string, err error)
- func ParseLsn(lsnStr string) (lsn uint64, err error)
- func ParsePageHeader(data []byte) (lsn uint64, valid bool)
- func ParseWALFileName(name string) (timelineId uint32, logSegNo uint64, err error)
- func ReadDatabaseFile(fileName string, lsn *uint64, isNew bool) (io.ReadCloser, bool, int64, error)
- func ResolveSymlink(path string) string
- func UploadWALFile(tarUploader *TarUploader, dirArc string, pre *S3Prefix, verify bool, ...)
- func WALFileName(lsn uint64, conn *pgx.Conn) (string, uint32, error)
- type Archive
- type Backup
- type BackupFileDescription
- type BackupFileList
- type BackupTime
- type BgUploader
- type Bundle
- func (bundle *Bundle) CheckSizeAndEnqueueBack(tarBall TarBall) error
- func (bundle *Bundle) CheckTimelineChanged(conn *pgx.Conn) bool
- func (bundle *Bundle) Deque() TarBall
- func (bundle *Bundle) EnqueueBack(tarBall TarBall, parallelOpInProgress *bool)
- func (bundle *Bundle) FinishQueue() error
- func (bundle *Bundle) GetFiles() *sync.Map
- func (bundle *Bundle) GetIncrementBaseFiles() BackupFileList
- func (bundle *Bundle) GetIncrementBaseLsn() *uint64
- func (bundle *Bundle) HandleLabelFiles(conn *pgx.Conn) (uint64, error)
- func (bundle *Bundle) HandleSentinel() error
- func (bundle *Bundle) NewTarBall(dedicatedUploader bool)
- func (bundle *Bundle) StartBackup(conn *pgx.Conn, backup string) (backupName string, lsn uint64, version int, err error)
- func (bundle *Bundle) StartQueue()
- func (bundle *Bundle) TarWalk(path string, info os.FileInfo, err error) error
- type CachedKey
- type CascadeWriteCloser
- type Cleaner
- type CompressingPipeWriter
- type CompressingPipeWriterError
- type Compressor
- type Crypter
- type Decompressor
- type DelayWriteCloser
- type DeleteCommandArguments
- type Empty
- type EmptyWriteIgnorer
- type FileSystemCleaner
- type FileTarInterpreter
- type IncrementalPageReader
- type LimitedReader
- type Lz4Compressor
- type Lz4Decompressor
- type LzmaCompressor
- type LzmaDecompressor
- type LzmaReaderFromWriter
- type LzoDecompressor
- type MD5Reader
- type NilWriter
- type NoMatchAvailableError
- type OpenPGPCrypter
- type PgQueryRunner
- func (queryRunner *PgQueryRunner) BuildGetVersion() string
- func (queryRunner *PgQueryRunner) BuildStartBackup() (string, error)
- func (queryRunner *PgQueryRunner) BuildStopBackup() (string, error)
- func (queryRunner *PgQueryRunner) StartBackup(backup string) (backupName string, lsnString string, inRecovery bool, err error)
- func (queryRunner *PgQueryRunner) StopBackup() (label string, offsetMap string, lsnStr string, err error)
- type QueryRunner
- type ReadCascadeCloser
- type ReaderFromWriteCloser
- type ReaderMaker
- type S3Prefix
- type S3ReaderMaker
- type S3TarBall
- func (tarBall *S3TarBall) AddSize(i int64)
- func (tarBall *S3TarBall) AwaitUploads()
- func (tarBall *S3TarBall) CloseTar() error
- func (tarBall *S3TarBall) FileExtension() string
- func (tarBall *S3TarBall) Finish(sentinelDto *S3TarBallSentinelDto) error
- func (tarBall *S3TarBall) SetUp(crypter Crypter, names ...string)
- func (tarBall *S3TarBall) Size() int64
- func (tarBall *S3TarBall) StartUpload(name string, crypter Crypter) io.WriteCloser
- func (tarBall *S3TarBall) TarWriter() *tar.Writer
- func (tarBall *S3TarBall) Trim() string
- type S3TarBallMaker
- type S3TarBallSentinelDto
- type Sentinel
- type TarBall
- type TarBallMaker
- type TarBundle
- type TarInterpreter
- type TarUploader
- type TimeSlice
- type UnknownCompressionMethodError
- type UnsetEnvVarError
- type UnsupportedFileTypeError
- type UntilEOFReader
- type ZeroReader
- type ZstdCompressor
- type ZstdDecompressor
- type ZstdReaderFromWriter
Constants ¶
const ( Lz4AlgorithmName = "lz4" LzmaAlgorithmName = "lzma" ZstdAlgorithmName = "zstd" Lz4FileExtension = "lz4" LzmaFileExtension = "lzma" ZstdFileExtension = "zst" LzoFileExtension = "lzo" )
const ( VersionStr = "005" BaseBackupsPath = "/basebackups_" + VersionStr + "/" WalPath = "/wal_" + VersionStr + "/" // SentinelSuffix is a suffix of backup finish sentinel file SentinelSuffix = "_backup_stop_sentinel.json" CompressedBlockMaxSize = 20 << 20 NotFoundAWSErrorCode = "NotFound" )
const ( // BlockSize is the PostgreSQL page size BlockSize uint16 = 8192 )
const DeleteUsageText = "delete requires at least 2 parameters" + `
retain 5 keep 5 backups
retain FULL 5 keep 5 full backups and all deltas of them
retail FIND_FULL 5 find necessary full for 5th and keep everything after it
before base_0123 keep everything after base_0123 including itself
before FIND_FULL base_0123 keep everything after the base of base_0123`
const LzopBlockSize = 256 * 1024
const ( // WalSegmentSize is the size of one WAL file WalSegmentSize = uint64(16 * 1024 * 1024) // xlog.c line 113ß )
Variables ¶
var Compressors = map[string]Compressor{ Lz4AlgorithmName: Lz4Compressor{}, LzmaAlgorithmName: LzmaCompressor{}, }
var Decompressors = []Decompressor{ Lz4Decompressor{}, ZstdDecompressor{}, LzmaDecompressor{}, }
var ErrCrypterUseMischief = errors.New("Crypter is not checked before use")
ErrCrypterUseMischief happens when crypter is used before initialization
var ErrInvalidBlock = errors.New("Block is not valid")
ErrInvalidBlock indicates that file contain invalid page and cannot be archived incrementally
var ErrLatestNotFound = errors.New("No backups found")
ErrLatestNotFound happens when users asks backup-fetch LATEST, but there is no backups
var ExcludedFilenames = make(map[string]Empty)
ExcludedFilenames is a list of excluded members from the bundled backup.
var MaxRetries = 15
MaxRetries limit upload and download retries during interaction with S3
Functions ¶
func ApplyFileIncrement ¶ added in v0.1.3
ApplyFileIncrement changes pages according to supplied change map file
func Configure ¶
func Configure() (*TarUploader, *S3Prefix, error)
Configure connects to S3 and creates an uploader. It makes sure that a valid session has started; if invalid, returns AWS error and `<nil>` values.
Requires these environment variables to be set: WALE_S3_PREFIX
Able to configure the upload part size in the S3 uploader.
func Connect ¶
Connect establishes a connection to postgres using a UNIX socket. Must export PGHOST and run with `sudo -E -u postgres`. If PGHOST is not set or if the connection fails, an error is returned and the connection is `<nil>`.
Example: PGHOST=/var/run/postgresql or PGHOST=10.0.0.1
func CreateUploader ¶
func CreateUploader(svc s3iface.S3API, partsize, concurrency int) s3manageriface.UploaderAPI
CreateUploader returns an uploader with customizable concurrency and partsize.
func DownloadAndDecompressWALFile ¶ added in v0.1.11
DownloadAndDecompressWALFile downloads a file and writes it to local file
func ExtractAll ¶
func ExtractAll(tarInterpreter TarInterpreter, files []ReaderMaker) error
ExtractAll Handles all files passed in. Supports `.lzo`, `.lz4`, `.lzma`, and `.tar`. File type `.nop` is used for testing purposes. Each file is extracted in its own goroutine and ExtractAll will wait for all goroutines to finish. Returns the first error encountered.
func FormatName ¶
FormatName grabs the name of the WAL file and returns it in the form of `base_...`. If no match is found, returns an empty string and a `NoMatchAvailableError`.
func GetBackupPath ¶ added in v0.1.4
GetBackupPath gets path for basebackup in a bucket
func GetFileExtension ¶ added in v0.1.11
func GetKeyRingId ¶ added in v0.1.3
func GetKeyRingId() string
GetKeyRingId extracts name of a key to use from env variable
func GetSentinelUserData ¶ added in v0.1.8
func GetSentinelUserData() interface{}
GetSentinelUserData tries to parse WALG_SENTINEL_USER_DATA env variable
func HandleBackupFetch ¶ added in v0.1.3
HandleBackupFetch is invoked to perform wal-g backup-fetch
func HandleBackupList ¶ added in v0.1.3
func HandleBackupList(pre *S3Prefix)
HandleBackupList is invoked to perform wal-g backup-list
func HandleBackupPush ¶ added in v0.1.3
func HandleBackupPush(dirArc string, tu *TarUploader, pre *S3Prefix)
HandleBackupPush is invoked to performa wal-g backup-push
func HandleDelete ¶ added in v0.1.3
HandleDelete is invoked to perform wal-g delete
func HandleTar ¶
HandleTar creates underlying tar writer and handles one given file. Does not follow symlinks. If file is in ExcludedFilenames, will not be included in the final tarball. EXCLUDED directories are created but their contents are not written to local disk.
func HandleWALFetch ¶ added in v0.1.3
HandleWALFetch is invoked to performa wal-g wal-fetch
func HandleWALPrefetch ¶ added in v0.1.3
HandleWALPrefetch is invoked by wal-fetch command to speed up database restoration
func HandleWALPush ¶ added in v0.1.3
func HandleWALPush(tarUploader *TarUploader, dirArc string, pre *S3Prefix, verify bool)
HandleWALPush is invoked to perform wal-g wal-push
func IsPagedFile ¶ added in v0.1.3
IsPagedFile checks basic expectaions for paged file
func MoveFileAndCreateDirs ¶ added in v0.1.3
MoveFileAndCreateDirs moves file from incremental folder to target folder, creating necessary folders structure
func NewDiskLimitReader ¶ added in v0.1.11
func NewDiskLimitReader(r io.ReadCloser) io.ReadCloser
NewDiskLimitReader returns a reader that is rate limited by disk limiter
func NewLzoReader ¶ added in v0.1.11
func NewLzoReader(r io.Reader) (io.ReadCloser, error)
func NewLzoWriter ¶ added in v0.1.11
func NewLzoWriter(w io.Writer) io.WriteCloser
func NewNetworkLimitReader ¶ added in v0.1.11
func NewNetworkLimitReader(r io.ReadCloser) io.ReadCloser
NewNetworkLimitReader returns a reader that is rate limited by network limiter
func NextWALFileName ¶ added in v0.1.3
NextWALFileName computes name of next WAL segment
func ParsePageHeader ¶ added in v0.1.3
ParsePageHeader reads information from PostgreSQL page header. Exported for test reasons.
func ParseWALFileName ¶ added in v0.1.3
ParseWALFileName extracts numeric parts from WAL file name
func ReadDatabaseFile ¶ added in v0.1.3
ReadDatabaseFile tries to read file as an incremental data file if possible, otherwise just open the file
func ResolveSymlink ¶ added in v0.1.4
ResolveSymlink converts path to physical if it is symlink
func UploadWALFile ¶ added in v0.1.5
func UploadWALFile(tarUploader *TarUploader, dirArc string, pre *S3Prefix, verify bool, bkgUpload bool)
UploadWALFile from FS to the cloud
Types ¶
type Archive ¶
Archive contains information associated with a WAL archive.
func (*Archive) CheckExistence ¶
CheckExistence checks that the specified WAL file exists.
func (*Archive) GetArchive ¶
func (archive *Archive) GetArchive() (io.ReadCloser, error)
GetArchive downloads the specified archive from S3.
type Backup ¶
Backup contains information about a valid backup generated and uploaded by WAL-G.
func (*Backup) CheckExistence ¶
CheckExistence checks that the specified backup exists.
func (*Backup) GetBackups ¶ added in v0.1.3
func (backup *Backup) GetBackups() ([]BackupTime, error)
GetBackups receives backup descriptions and sorts them by time
type BackupFileDescription ¶ added in v0.1.3
type BackupFileList ¶ added in v0.1.3
type BackupFileList map[string]BackupFileDescription
type BackupTime ¶
BackupTime is used to sort backups by latest modified time.
func GetBackupTimeSlices ¶ added in v0.1.3
func GetBackupTimeSlices(backups []*s3.Object) []BackupTime
GetBackupTimeSlices converts S3 objects to backup description
type BgUploader ¶ added in v0.1.5
type BgUploader struct {
// contains filtered or unexported fields
}
BgUploader represents the state of concurrent WAL upload
func (*BgUploader) Start ¶ added in v0.1.5
func (uploader *BgUploader) Start(walFilePath string, maxParallelWorkers int32, tu *TarUploader, pre *S3Prefix, verify bool)
Start up checking what's inside archive_status
func (*BgUploader) Upload ¶ added in v0.1.5
func (uploader *BgUploader) Upload(info os.FileInfo)
Upload one WAL file
type Bundle ¶
type Bundle struct { MinSize int64 Sentinel *Sentinel TarBall TarBall TarBallMaker TarBallMaker Crypter OpenPGPCrypter Timeline uint32 Replica bool IncrementFromLsn *uint64 IncrementFromFiles BackupFileList Files *sync.Map // contains filtered or unexported fields }
A Bundle represents the directory to be walked. Contains at least one TarBall if walk has started. Each TarBall will be at least MinSize bytes. The Sentinel is used to ensure complete uploaded backups; in this case, pg_control is used as the sentinel.
func (*Bundle) CheckSizeAndEnqueueBack ¶ added in v0.1.8
func (*Bundle) CheckTimelineChanged ¶ added in v0.1.3
CheckTimelineChanged compares timelines of pg_backup_start() and pg_backup_stop()
func (*Bundle) EnqueueBack ¶ added in v0.1.8
func (*Bundle) FinishQueue ¶ added in v0.1.8
func (*Bundle) GetIncrementBaseFiles ¶ added in v0.1.3
func (bundle *Bundle) GetIncrementBaseFiles() BackupFileList
GetIncrementBaseFiles returns list of Files from previous backup
func (*Bundle) GetIncrementBaseLsn ¶ added in v0.1.3
GetIncrementBaseLsn returns LSN of previous backup
func (*Bundle) HandleLabelFiles ¶
HandleLabelFiles creates the `backup_label` and `tablespace_map` Files and uploads it to S3 by stopping the backup. Returns error upon failure.
func (*Bundle) HandleSentinel ¶
HandleSentinel uploads the compressed tar file of `pg_control`. Will only be called after the rest of the backup is successfully uploaded to S3. Returns an error upon failure.
func (*Bundle) NewTarBall ¶
NewTarBall starts writing new tarball
func (*Bundle) StartBackup ¶ added in v0.1.3
func (bundle *Bundle) StartBackup(conn *pgx.Conn, backup string) (backupName string, lsn uint64, version int, err error)
StartBackup starts a non-exclusive base backup immediately. When finishing the backup, `backup_label` and `tablespace_map` contents are not immediately written to a file but returned instead. Returns empty string and an error if backup fails.
func (*Bundle) StartQueue ¶ added in v0.1.8
func (bundle *Bundle) StartQueue()
func (*Bundle) TarWalk ¶ added in v0.1.11
TarWalk walks files provided by the passed in directory and creates compressed tar members labeled as `part_00i.tar.lzo`.
To see which files and directories are Skipped, please consult ExcludedFilenames. Excluded directories will be created but their contents will not be included in the tar bundle.
type CachedKey ¶ added in v0.1.3
CachedKey is the data transfer object describing format of key ring cache
type CascadeWriteCloser ¶ added in v0.1.11
type CascadeWriteCloser struct { io.WriteCloser Underlying io.Closer }
CascadeWriteCloser bundles multiple closures into one function. Calling Close() will close the main and underlying writers.
func (*CascadeWriteCloser) Close ¶ added in v0.1.11
func (cascadeCloser *CascadeWriteCloser) Close() error
Close returns the first encountered error from closing main or underlying writer.
type Cleaner ¶ added in v0.1.3
Cleaner interface serves to separate file system logic from prefetch clean logic to make it testable
type CompressingPipeWriter ¶ added in v0.1.11
type CompressingPipeWriter struct { Input io.Reader Output io.Reader NewCompressingWriter func(io.Writer) ReaderFromWriteCloser }
CompressingPipeWriter allows for flexibility of using compressed output. Input is read and compressed to a pipe reader.
func NewLz4CompressingPipeWriter ¶ added in v0.1.11
func NewLz4CompressingPipeWriter(input io.Reader) *CompressingPipeWriter
func (*CompressingPipeWriter) Compress ¶ added in v0.1.11
func (pipeWriter *CompressingPipeWriter) Compress(crypter Crypter)
Compress compresses input to a pipe reader. Output must be used or pipe will block.
type CompressingPipeWriterError ¶ added in v0.1.11
type CompressingPipeWriterError struct {
// contains filtered or unexported fields
}
CompressingPipeWriterError is used to catch specific errors from CompressingPipeWriter when uploading to S3. Will not retry upload if this error occurs.
func (CompressingPipeWriterError) Error ¶ added in v0.1.11
func (err CompressingPipeWriterError) Error() string
type Compressor ¶ added in v0.1.11
type Compressor interface { NewWriter(writer io.Writer) ReaderFromWriteCloser FileExtension() string }
type Crypter ¶ added in v0.1.3
type Crypter interface { IsUsed() bool Encrypt(writer io.WriteCloser) (io.WriteCloser, error) Decrypt(reader io.ReadCloser) (io.Reader, error) }
Crypter is responsible for making cryptographical pipeline parts when needed
type Decompressor ¶ added in v0.1.11
type DelayWriteCloser ¶ added in v0.1.3
type DelayWriteCloser struct {
// contains filtered or unexported fields
}
DelayWriteCloser delays first writes. Encryption starts writing header immediately. But there is a lot of places where writer is instantiated long before pipe is ready. This is why here is used special writer, which delays encryption initialization before actual write. If no write occurs, initialization still is performed, to handle zero-byte Files correctly
func (*DelayWriteCloser) Close ¶ added in v0.1.3
func (delayWriteCloser *DelayWriteCloser) Close() error
Close DelayWriteCloser
type DeleteCommandArguments ¶ added in v0.1.3
type DeleteCommandArguments struct {
// contains filtered or unexported fields
}
DeleteCommandArguments incapsulates arguments for delete command
func ParseDeleteArguments ¶ added in v0.1.3
func ParseDeleteArguments(args []string, fallBackFunc func()) (result DeleteCommandArguments)
ParseDeleteArguments interprets arguments for delete command. TODO: use flags or cobra
type EmptyWriteIgnorer ¶
type EmptyWriteIgnorer struct {
io.WriteCloser
}
EmptyWriteIgnorer handles 0 byte write in LZ4 package to stop pipe reader/writer from blocking.
type FileSystemCleaner ¶ added in v0.1.3
type FileSystemCleaner struct{}
FileSystemCleaner actually performs it's functions on file system
func (FileSystemCleaner) GetFiles ¶ added in v0.1.3
func (c FileSystemCleaner) GetFiles(directory string) (files []string, err error)
GetFiles of a directory
func (FileSystemCleaner) Remove ¶ added in v0.1.3
func (c FileSystemCleaner) Remove(file string)
Remove file
type FileTarInterpreter ¶
type FileTarInterpreter struct { NewDir string Sentinel S3TarBallSentinelDto IncrementalBaseDir string }
FileTarInterpreter extracts input to disk.
type IncrementalPageReader ¶ added in v0.1.3
type IncrementalPageReader struct {
// contains filtered or unexported fields
}
IncrementalPageReader constructs difference map during initialization and than re-read file Diff map can be of 1Gb/PostgresBlockSize elements == 512Kb
func (*IncrementalPageReader) Close ¶ added in v0.1.3
func (pageReader *IncrementalPageReader) Close() error
Close IncrementalPageReader
type LimitedReader ¶ added in v0.1.11
type LimitedReader struct {
// contains filtered or unexported fields
}
func (*LimitedReader) Close ¶ added in v0.1.11
func (r *LimitedReader) Close() error
type Lz4Compressor ¶ added in v0.1.11
type Lz4Compressor struct{}
func (Lz4Compressor) FileExtension ¶ added in v0.1.11
func (compressor Lz4Compressor) FileExtension() string
func (Lz4Compressor) NewWriter ¶ added in v0.1.11
func (compressor Lz4Compressor) NewWriter(writer io.Writer) ReaderFromWriteCloser
type Lz4Decompressor ¶ added in v0.1.11
type Lz4Decompressor struct{}
func (Lz4Decompressor) Decompress ¶ added in v0.1.11
func (Lz4Decompressor) FileExtension ¶ added in v0.1.11
func (decompressor Lz4Decompressor) FileExtension() string
type LzmaCompressor ¶ added in v0.1.11
type LzmaCompressor struct{}
func (LzmaCompressor) FileExtension ¶ added in v0.1.11
func (compressor LzmaCompressor) FileExtension() string
func (LzmaCompressor) NewWriter ¶ added in v0.1.11
func (compressor LzmaCompressor) NewWriter(writer io.Writer) ReaderFromWriteCloser
type LzmaDecompressor ¶ added in v0.1.11
type LzmaDecompressor struct{}
func (LzmaDecompressor) Decompress ¶ added in v0.1.11
func (LzmaDecompressor) FileExtension ¶ added in v0.1.11
func (decompressor LzmaDecompressor) FileExtension() string
type LzmaReaderFromWriter ¶ added in v0.1.11
func NewLzmaReaderFromWriter ¶ added in v0.1.11
func NewLzmaReaderFromWriter(dst io.Writer) (*LzmaReaderFromWriter, error)
type LzoDecompressor ¶ added in v0.1.11
type LzoDecompressor struct{}
func (LzoDecompressor) Decompress ¶ added in v0.1.11
func (LzoDecompressor) FileExtension ¶ added in v0.1.11
func (decompressor LzoDecompressor) FileExtension() string
type MD5Reader ¶ added in v0.1.11
type MD5Reader struct {
// contains filtered or unexported fields
}
type NoMatchAvailableError ¶
type NoMatchAvailableError struct {
// contains filtered or unexported fields
}
NoMatchAvailableError is used to signal no match found in string.
func (NoMatchAvailableError) Error ¶
func (e NoMatchAvailableError) Error() string
type OpenPGPCrypter ¶ added in v0.1.3
type OpenPGPCrypter struct {
// contains filtered or unexported fields
}
OpenPGPCrypter incapsulates specific of cypher method Includes keys, infrastructutre information etc If many encryption methods will be used it worth to extract interface
func (*OpenPGPCrypter) ConfigureGPGCrypter ¶ added in v0.1.3
func (crypter *OpenPGPCrypter) ConfigureGPGCrypter()
ConfigureGPGCrypter is OpenPGPCrypter internal initialization
func (*OpenPGPCrypter) Decrypt ¶ added in v0.1.3
func (crypter *OpenPGPCrypter) Decrypt(reader io.ReadCloser) (io.Reader, error)
Decrypt creates decrypted reader from ordinary reader
func (*OpenPGPCrypter) Encrypt ¶ added in v0.1.3
func (crypter *OpenPGPCrypter) Encrypt(writer io.WriteCloser) (io.WriteCloser, error)
Encrypt creates encryption writer from ordinary writer
func (*OpenPGPCrypter) IsUsed ¶ added in v0.1.3
func (crypter *OpenPGPCrypter) IsUsed() bool
IsUsed is to check necessity of Crypter use Must be called prior to any other crypter call
type PgQueryRunner ¶ added in v0.1.8
type PgQueryRunner struct { Version int // contains filtered or unexported fields }
PgQueryRunner is implementation for controlling PostgreSQL 9.0+
func NewPgQueryRunner ¶ added in v0.1.8
func NewPgQueryRunner(conn *pgx.Conn) (*PgQueryRunner, error)
NewPgQueryRunner builds QueryRunner from available connection
func (*PgQueryRunner) BuildGetVersion ¶ added in v0.1.8
func (queryRunner *PgQueryRunner) BuildGetVersion() string
BuildGetVersion formats a query to retrieve PostgreSQL numeric version
func (*PgQueryRunner) BuildStartBackup ¶ added in v0.1.8
func (queryRunner *PgQueryRunner) BuildStartBackup() (string, error)
BuildStartBackup formats a query that starts backup according to server features and version
func (*PgQueryRunner) BuildStopBackup ¶ added in v0.1.8
func (queryRunner *PgQueryRunner) BuildStopBackup() (string, error)
BuildStopBackup formats a query that stops backup according to server features and version
func (*PgQueryRunner) StartBackup ¶ added in v0.1.8
func (queryRunner *PgQueryRunner) StartBackup(backup string) (backupName string, lsnString string, inRecovery bool, err error)
StartBackup informs the database that we are starting copy of cluster contents
func (*PgQueryRunner) StopBackup ¶ added in v0.1.8
func (queryRunner *PgQueryRunner) StopBackup() (label string, offsetMap string, lsnStr string, err error)
StopBackup informs the database that copy is over
type QueryRunner ¶ added in v0.1.8
type QueryRunner interface { // This call should inform the database that we are going to copy cluster's contents // Should fail if backup is currently impossible StartBackup(backup string) (string, string, bool, error) // Inform database that contents are copied, get information on backup StopBackup() (string, string, string, error) }
The QueryRunner interface for controlling database during backup
type ReadCascadeCloser ¶ added in v0.1.11
ReadCascadeCloser composes io.ReadCloser from two parts
type ReaderFromWriteCloser ¶ added in v0.1.11
type ReaderFromWriteCloser interface { io.ReaderFrom io.WriteCloser }
type ReaderMaker ¶
type ReaderMaker interface { Reader() (io.ReadCloser, error) Format() string Path() string }
ReaderMaker is the generic interface used by extract. It allows for ease of handling different file formats.
type S3ReaderMaker ¶
S3ReaderMaker handles cases where backups need to be uploaded to S3.
func (*S3ReaderMaker) Format ¶
func (readerMaker *S3ReaderMaker) Format() string
func (*S3ReaderMaker) Reader ¶
func (readerMaker *S3ReaderMaker) Reader() (io.ReadCloser, error)
Reader creates a new S3 reader for each S3 object.
type S3TarBall ¶
type S3TarBall struct { Lsn *uint64 IncrementFromLsn *uint64 IncrementFrom string Files BackupFileList // contains filtered or unexported fields }
S3TarBall represents a tar file that is going to be uploaded to S3.
func (*S3TarBall) AwaitUploads ¶ added in v0.1.8
func (tarBall *S3TarBall) AwaitUploads()
func (*S3TarBall) CloseTar ¶
CloseTar closes the tar writer, flushing any unwritten data to the underlying writer before also closing the underlying writer.
func (*S3TarBall) FileExtension ¶ added in v0.1.11
func (*S3TarBall) Finish ¶
func (tarBall *S3TarBall) Finish(sentinelDto *S3TarBallSentinelDto) error
Finish writes a .json file description and uploads it with the the backup name. Finish will wait until all tar file parts have been uploaded. The json file will only be uploaded if all other parts of the backup are present in S3. an alert is given with the corresponding error.
func (*S3TarBall) SetUp ¶
SetUp creates a new tar writer and starts upload to S3. Upload will block until the tar file is finished writing. If a name for the file is not given, default name is of the form `part_....tar.[Compressor file extension]`.
func (*S3TarBall) StartUpload ¶
func (tarBall *S3TarBall) StartUpload(name string, crypter Crypter) io.WriteCloser
StartUpload creates a compressing writer and runs upload in the background once a compressed tar member is finished writing.
type S3TarBallMaker ¶
type S3TarBallMaker struct { Trim string BkupName string TarUploader *TarUploader Lsn *uint64 IncrementFromLsn *uint64 IncrementFrom string // contains filtered or unexported fields }
S3TarBallMaker creates tarballs that are uploaded to S3.
func (*S3TarBallMaker) Make ¶
func (tarBallMaker *S3TarBallMaker) Make(dedicatedUploader bool) TarBall
Make returns a tarball with required S3 fields.
type S3TarBallSentinelDto ¶ added in v0.1.3
type S3TarBallSentinelDto struct { LSN *uint64 IncrementFromLSN *uint64 `json:"DeltaFromLSN,omitempty"` IncrementFrom *string `json:"DeltaFrom,omitempty"` IncrementFullName *string `json:"DeltaFullName,omitempty"` IncrementCount *int `json:"DeltaCount,omitempty"` Files BackupFileList PgVersion int FinishLSN *uint64 UserData interface{} `json:"UserData,omitempty"` }
S3TarBallSentinelDto describes file structure of json sentinel
func (*S3TarBallSentinelDto) IsIncremental ¶ added in v0.1.3
func (dto *S3TarBallSentinelDto) IsIncremental() bool
IsIncremental checks that sentinel represents delta backup
func (*S3TarBallSentinelDto) SetFiles ¶ added in v0.1.8
func (dto *S3TarBallSentinelDto) SetFiles(p *sync.Map)
type TarBall ¶
type TarBall interface { SetUp(crypter Crypter, args ...string) CloseTar() error Finish(sentinelDto *S3TarBallSentinelDto) error Trim() string Size() int64 AddSize(int64) TarWriter() *tar.Writer FileExtension() string AwaitUploads() }
A TarBall represents one tar file.
type TarBallMaker ¶
TarBallMaker is used to allow for flexible creation of different TarBalls.
type TarBundle ¶
type TarBundle interface { NewTarBall(dedicatedUploader bool) GetIncrementBaseLsn() *uint64 GetIncrementBaseFiles() BackupFileList StartQueue() Deque() TarBall EnqueueBack(tarBall TarBall, parallelOpInProgress *bool) CheckSizeAndEnqueueBack(tarBall TarBall) error FinishQueue() error GetFiles() *sync.Map }
TarBundle represents one completed directory.
type TarInterpreter ¶
TarInterpreter behaves differently for different file types.
type TarUploader ¶
type TarUploader struct { UploaderApi s3manageriface.UploaderAPI ServerSideEncryption string SSEKMSKeyId string StorageClass string Success bool // contains filtered or unexported fields }
TarUploader contains fields associated with uploading tarballs. Multiple tarballs can share one uploader. Must call CreateUploader() in 'upload.go'.
func NewLz4MockTarUploader ¶ added in v0.1.11
func NewLz4MockTarUploader() *TarUploader
func NewTarUploader ¶
func NewTarUploader(bucket, server, compressionMethod string) *TarUploader
NewTarUploader creates a new tar uploader without the actual S3 uploader. CreateUploader() is used to configure byte size and concurrency streams for the uploader.
func (*TarUploader) Clone ¶ added in v0.1.7
func (tarUploader *TarUploader) Clone() *TarUploader
Clone creates similar TarUploader with new WaitGroup
func (*TarUploader) Finish ¶
func (tarUploader *TarUploader) Finish()
Finish waits for all waiting parts to be uploaded. If an error occurs, prints alert to stderr.
type TimeSlice ¶
type TimeSlice []BackupTime
TimeSlice represents a backup and its last modified time.
type UnknownCompressionMethodError ¶ added in v0.1.11
type UnknownCompressionMethodError struct{}
func (UnknownCompressionMethodError) Error ¶ added in v0.1.11
func (err UnknownCompressionMethodError) Error() string
type UnsetEnvVarError ¶
type UnsetEnvVarError struct {
// contains filtered or unexported fields
}
UnsetEnvVarError is used to indicate required environment variables for WAL-G.
func (UnsetEnvVarError) Error ¶
func (e UnsetEnvVarError) Error() string
type UnsupportedFileTypeError ¶
UnsupportedFileTypeError is used to signal file types that are unsupported by WAL-G.
func (UnsupportedFileTypeError) Error ¶
func (e UnsupportedFileTypeError) Error() string
type UntilEOFReader ¶ added in v0.1.11
type UntilEOFReader struct {
// contains filtered or unexported fields
}
func NewUntilEofReader ¶ added in v0.1.11
func NewUntilEofReader(underlying io.Reader) *UntilEOFReader
type ZeroReader ¶
type ZeroReader struct{}
ZeroReader generates a slice of zeroes. Used to pad tar in cases where length of file changes.
type ZstdCompressor ¶ added in v0.1.11
type ZstdCompressor struct{}
func (ZstdCompressor) FileExtension ¶ added in v0.1.11
func (compressor ZstdCompressor) FileExtension() string
func (ZstdCompressor) NewWriter ¶ added in v0.1.11
func (compressor ZstdCompressor) NewWriter(writer io.Writer) ReaderFromWriteCloser
type ZstdDecompressor ¶ added in v0.1.11
type ZstdDecompressor struct{}
func (ZstdDecompressor) Decompress ¶ added in v0.1.11
func (ZstdDecompressor) FileExtension ¶ added in v0.1.11
func (decompressor ZstdDecompressor) FileExtension() string
type ZstdReaderFromWriter ¶ added in v0.1.11
func NewZstdReaderFromWriter ¶ added in v0.1.11
func NewZstdReaderFromWriter(dst io.Writer) *ZstdReaderFromWriter
Source Files ¶
- archive.go
- backup.go
- backup_file_description.go
- backup_time.go
- bandwidth_limiter.go
- bguploader.go
- bundle.go
- cascade_closer.go
- commands.go
- compressing_pipe_writer.go
- compression.go
- connect.go
- crypter.go
- crypto.go
- delay_write_closer.go
- delete.go
- errors.go
- extract.go
- io_utils.go
- lz4_compressor.go
- lz4_decompressor.go
- lzma_compressor.go
- lzma_decompressor.go
- lzma_reader_from_writer.go
- lzo_decompressor.go
- lzo_disabled.go
- md5_reader.go
- open_pgp_crypter.go
- pagefile.go
- prefetch.go
- queryRunner.go
- read_cascade_close.go
- reader_maker.go
- s3_prefix.go
- s3_reader_maker.go
- s3_tar_ball.go
- s3_tar_ball_maker.go
- s3_tar_ball_sentinel_dto.go
- sentinel.go
- tar.go
- tar_ball.go
- tar_ball_maker.go
- tar_bundle.go
- tar_uploader.go
- time_slice.go
- timeline.go
- upload.go
- utility.go
- utility_for_tests.go
- walk.go
- zstd_compressor.go
- zstd_decompressor.go
- zstd_reader_from_writer.go