Documentation
¶
Index ¶
- Constants
- Variables
- func ApplyFileIncrement(fileName string, increment io.Reader) error
- func CleanupPrefetchDirectories(walFileName string, location string, cleaner Cleaner)
- func ComputeDeletionSkipline(backups []BackupTime, target *Backup) (skipLine int, walSkipFileName string)
- func Configure(verifyUploads bool) (uploader *Uploader, destinationFolder *S3Folder, err error)
- func Connect() (*pgx.Conn, error)
- func CreateFileWith(filePath string, content io.Reader) error
- func CreateUploader(svc s3iface.S3API, partsize, concurrency int) s3manageriface.UploaderAPI
- func DecryptAndDecompressTar(writer io.Writer, readerMaker ReaderMaker, crypter Crypter) error
- func ExtractAll(tarInterpreter TarInterpreter, files []ReaderMaker) error
- func ExtractBlockLocations(records []walparser.XLogRecord) []walparser.BlockLocation
- func FastCopy(dst io.Writer, src io.Reader) (int64, error)
- func GetBackupPath(folder *S3Folder) string
- func GetDeltaFilenameFor(walFilename string) (string, error)
- func GetFileExtension(filePath string) string
- func GetFileRelativePath(fileAbsPath string, directoryPath string) string
- func GetKeyRingId() string
- func GetLatestBackupKey(folder *S3Folder) (string, error)
- func GetNextWalFilename(name string) (string, error)
- func GetPositionInDelta(walFilename string) int
- func GetPrefetchLocations(location string, walFileName string) (prefetchLocation string, runningLocation string, runningFile string, ...)
- func GetRelFileIdFrom(filePath string) (int, error)
- func GetRelFileNodeFrom(filePath string) (*walparser.RelFileNode, error)
- func GetSentinelUserData() interface{}
- func HandleBackupFetch(backupName string, folder *S3Folder, archiveDirectory string, mem bool) (lsn *uint64)
- func HandleBackupList(folder *S3Folder)
- func HandleBackupPush(archiveDirectory string, uploader *Uploader)
- func HandleDelete(folder *S3Folder, args []string)
- func HandleWALFetch(folder *S3Folder, walFileName string, location string, triggerPrefetch bool)
- func HandleWALPrefetch(folder *S3Folder, walFileName string, location string, uploader *Uploader)
- func HandleWALPush(uploader *Uploader, walFilePath string)
- func IsAwsNotExist(err error) bool
- func LookupConfigValue(key string) (value string, ok bool)
- 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 PackFileTo(tarBall TarBall, fileInfoHeader *tar.Header, fileContent io.Reader) (fileSize int64, err error)
- func ParseWALFilename(name string) (timelineId uint32, logSegNo uint64, err error)
- func ReadIncrementFileHeader(reader io.Reader) error
- func ReadIncrementalFile(filePath string, fileSize int64, lsn uint64, deltaBitmap *roaring.Bitmap) (fileReader io.ReadCloser, size int64, err error)
- func ReadLocationsFrom(reader io.Reader) ([]walparser.BlockLocation, error)
- func ResolveSymlink(path string) string
- func SelectRelFileBlocks(bitmap *roaring.Bitmap, relFileId int) *roaring.Bitmap
- func ShouldPrefault(name string) (lsn uint64, shouldPrefault bool, timelineId uint32, err error)
- func ToBytes(x interface{}) []byte
- func ToPartFilename(deltaFilename string) string
- func TryDownloadWALFile(folder *S3Folder, walPath string) (archiveReader io.ReadCloser, exists bool, err error)
- func WriteLocationsTo(writer io.Writer, locations []walparser.BlockLocation) error
- type Archive
- type ArchiveNonExistenceError
- type Backup
- type BackupFileDescription
- type BackupFileList
- type BackupTime
- type BgUploader
- type BlockLocationReader
- type BlockLocationWriter
- type BrotliCompressor
- type BrotliDecompressor
- type BrotliReaderFromWriter
- type Bundle
- func (bundle *Bundle) CheckSizeAndEnqueueBack(tarBall TarBall) error
- func (bundle *Bundle) Deque() TarBall
- func (bundle *Bundle) DownloadDeltaMap(folder *S3Folder, backupStartLSN uint64) error
- func (bundle *Bundle) EnqueueBack(tarBall TarBall)
- func (bundle *Bundle) FinishQueue() error
- func (bundle *Bundle) GetFileRelPath(fileAbsPath string) string
- func (bundle *Bundle) GetFiles() *sync.Map
- func (bundle *Bundle) GetIncrementBaseFiles() BackupFileList
- func (bundle *Bundle) GetIncrementBaseLsn() *uint64
- func (bundle *Bundle) HandleWalkedFSObject(path string, info os.FileInfo, err error) error
- func (bundle *Bundle) NewTarBall(dedicatedUploader bool)
- func (bundle *Bundle) PrefaultWalkedFSObject(path string, info os.FileInfo, err error) error
- func (bundle *Bundle) StartBackup(conn *pgx.Conn, backup string) (backupName string, lsn uint64, version int, err error)
- func (bundle *Bundle) StartQueue()
- func (bundle *Bundle) UploadLabelFiles(conn *pgx.Conn) (uint64, error)
- func (bundle *Bundle) UploadPgControl(compressorFileExtension string) error
- type CachedKey
- type CascadeWriteCloser
- type Cleaner
- type CompressingPipeWriter
- type CompressingPipeWriterError
- type Compressor
- type Crypter
- type DataFolder
- type Decompressor
- type DelayWriteCloser
- type DeleteCommandArguments
- type DeltaFile
- type DeltaFileChanWriter
- type DeltaFileManager
- func (manager *DeltaFileManager) CancelRecording(walFilename string)
- func (manager *DeltaFileManager) CombinePartFile(deltaFilename string, partFile *WalPartFile) error
- func (manager *DeltaFileManager) FlushDeltaFiles(uploader *Uploader, completedPartFiles map[string]bool)
- func (manager *DeltaFileManager) FlushFiles(uploader *Uploader)
- func (manager *DeltaFileManager) FlushPartFiles() (completedPartFiles map[string]bool)
- func (manager *DeltaFileManager) GetBlockLocationConsumer(deltaFilename string) (chan walparser.BlockLocation, error)
- func (manager *DeltaFileManager) GetPartFile(deltaFilename string) (*WalPartFile, error)
- func (manager *DeltaFileManager) LoadDeltaFileWriter(deltaFilename string) (deltaFileWriter *DeltaFileChanWriter, err error)
- func (manager *DeltaFileManager) LoadPartFile(partFilename string) (*WalPartFile, error)
- type DeltaFileWriterNotFoundError
- type DiskDataFolder
- type Empty
- type EmptyWriteIgnorer
- type FileSystemCleaner
- type FileTarInterpreter
- type IncrementalPageReader
- func (pageReader *IncrementalPageReader) AdvanceFileReader() error
- func (pageReader *IncrementalPageReader) Close() error
- func (pageReader *IncrementalPageReader) DeltaBitmapInitialize(deltaBitmap *roaring.Bitmap)
- func (pageReader *IncrementalPageReader) DrainMoreData() (succeed bool, err error)
- func (pageReader *IncrementalPageReader) FullScanInitialize() error
- func (pageReader *IncrementalPageReader) Read(p []byte) (n int, err error)
- func (pageReader *IncrementalPageReader) SelectNewValidPage(pageBytes []byte, blockNo uint32) (valid bool)
- func (pageReader *IncrementalPageReader) WriteDiffMapToHeader(headerWriter io.Writer)
- type InvalidBlockError
- type LazyCache
- func (lazyCache *LazyCache) Load(key interface{}) (value interface{}, exists bool, err error)
- func (lazyCache *LazyCache) LoadExisting(key interface{}) (value interface{}, exists bool)
- func (lazyCache *LazyCache) Range(reduce func(key, value interface{}) bool)
- func (lazyCache *LazyCache) Store(key, value interface{})
- type LimitedReader
- type Lz4Compressor
- type Lz4Decompressor
- type Lz4ReaderFromWriter
- type LzmaCompressor
- type LzmaDecompressor
- type LzmaReaderFromWriter
- type LzoDecompressor
- type MD5Reader
- type NOPTarBall
- func (tarBall *NOPTarBall) AddSize(i int64)
- func (tarBall *NOPTarBall) AwaitUploads()
- func (tarBall *NOPTarBall) CloseTar() error
- func (tarBall *NOPTarBall) Finish(sentinelDto *S3TarBallSentinelDto) error
- func (tarBall *NOPTarBall) SetUp(crypter Crypter, params ...string)
- func (tarBall *NOPTarBall) Size() int64
- func (tarBall *NOPTarBall) TarWriter() *tar.Writer
- type NOPTarBallMaker
- type NamedReader
- type NamedReaderImpl
- type NoSuchFileError
- type NotWalFilenameError
- type OpenPGPCrypter
- func (crypter *OpenPGPCrypter) ConfigureGPGCrypter()
- func (crypter *OpenPGPCrypter) Decrypt(reader io.ReadCloser) (io.Reader, error)
- func (crypter *OpenPGPCrypter) Encrypt(writer io.WriteCloser) (io.WriteCloser, error)
- func (crypter *OpenPGPCrypter) IsArmed() bool
- func (crypter *OpenPGPCrypter) IsUsed() bool
- type PagedFileDeltaMap
- 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 PostgresPageHeader
- type QueryRunner
- type ReadCascadeCloser
- type ReadSeekCloser
- type ReadSeekCloserImpl
- type ReaderFromWriteCloser
- type ReaderMaker
- type S3Folder
- type S3ReaderMaker
- type S3TarBall
- func (tarBall *S3TarBall) AddSize(i int64)
- func (tarBall *S3TarBall) AwaitUploads()
- func (tarBall *S3TarBall) CloseTar() error
- func (tarBall *S3TarBall) Finish(sentinelDto *S3TarBallSentinelDto) error
- func (tarBall *S3TarBall) SetUp(crypter Crypter, names ...string)
- func (tarBall *S3TarBall) Size() int64
- func (tarBall *S3TarBall) TarWriter() *tar.Writer
- type S3TarBallMaker
- type S3TarBallSentinelDto
- type Saver
- type Sentinel
- type TarBall
- type TarBallMaker
- type TarInterpreter
- type TimeSlice
- type UnknownCompressionMethodError
- type UnsetEnvVarError
- type UnsupportedFileTypeError
- type UntilEOFReader
- type Uploader
- type WalDeltaRecorder
- type WalDeltaRecordingReader
- type WalPart
- type WalPartDataType
- type WalPartFile
- type WalPartRecorder
- type WrongTypeError
- type ZeroReader
- type ZstdCompressor
- type ZstdDecompressor
- type ZstdReaderFromWriter
Constants ¶
const ( DefaultTarSizeThreshold = int64((1 << 30) - 1) PgControl = "pg_control" )
It is made so to load big database files of size 1GB one by one
const ( Lz4AlgorithmName = "lz4" LzmaAlgorithmName = "lzma" ZstdAlgorithmName = "zstd" BrotliAlgorithmName = "brotli" Lz4FileExtension = "lz4" LzmaFileExtension = "lzma" ZstdFileExtension = "zst" BrotliFileExtension = "br" LzoFileExtension = "lzo" )
const ( DefaultStreamingPartSizeFor10Concurrency = 20 << 20 DefaultDataBurstRateLimit = 8 * int64(DatabasePageSize) )
const ( RelFileSizeBound = 1 << 30 BlocksInRelFile = RelFileSizeBound / int(DatabasePageSize) DefaultSpcNode walparser.Oid = 1663 )
const ( DatabasePageSize = walparser.BlockSize SignatureMagicNumber byte = 0x55 DefaultTablespace = "base" GlobalTablespace = "global" NonDefaultTablespace = "pg_tblspc" )
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" NoSuchKeyAWSErrorCode = "NoSuchKey" )
const ( WalFileInDelta uint64 = 16 DeltaFilenameSuffix = "_delta" PartFilenameSuffix = "_part" )
const DefaultDataFolderPath = "/tmp"
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
retain 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 GpgBin = "gpg"
const LzopBlockSize = 256 * 1024
const (
RecordPartFilename = "currentRecord.part"
)
const TotalBgUploadedLimit = 1024
const ( // WalSegmentSize is the size of one WAL file WalSegmentSize = uint64(16 * 1024 * 1024) // xlog.c line 113ß )
Variables ¶
var CompressingAlgorithms = []string{Lz4AlgorithmName, LzmaAlgorithmName, ZstdAlgorithmName, BrotliAlgorithmName}
var Compressors = map[string]Compressor{ Lz4AlgorithmName: Lz4Compressor{}, LzmaAlgorithmName: LzmaCompressor{}, BrotliAlgorithmName: BrotliCompressor{}, ZstdAlgorithmName: ZstdCompressor{}, }
var Decompressors = []Decompressor{ Lz4Decompressor{}, BrotliDecompressor{}, LzmaDecompressor{}, ZstdDecompressor{}, }
var DiskLimiter *rate.Limiter
var ErrCrypterUseMischief = errors.New("Crypter is not checked before use")
ErrCrypterUseMischief happens when crypter is used before initialization
var ExcludedFilenames = make(map[string]Empty)
ExcludedFilenames is a list of excluded members from the bundled backup.
var IncrementFileHeader = []byte{'w', 'i', '1', SignatureMagicNumber}
"wi" at the head stands for "wal-g increment" format version "1", signature magic number
var InvalidIncrementFileHeaderError = errors.New("Invalid increment file header")
var InvalidWalFileMagicError = errors.New("WAL-G: WAL file magic is invalid ")
var MaxRetries = 15
MaxRetries limit upload and download retries during interaction with S3
var NetworkLimiter *rate.Limiter
var NilWalParserError = errors.New("expected to get non nil wal parser, but got nil one")
var NoBackupsFoundError = errors.New("No backups found")
var NoBitmapFoundError = errors.New("GetDeltaBitmapFor: no bitmap found")
var NoFilesToExtractError = errors.New("ExtractAll: did not provide files to extract")
var PgControlMissingError = errors.New("Corrupted backup: missing pg_control")
var TerminalLocation = *walparser.NewBlockLocation(0, 0, 0, 0)
var UnexpectedTarDataError = errors.New("Expected end of Tar")
var UnknownIncrementFileHeaderError = errors.New("Unknown increment file header")
var UnknownTableSpaceError = errors.New("GetRelFileNodeFrom: unknown tablespace")
var (
WalgConfig *map[string]string
)
Functions ¶
func ApplyFileIncrement ¶ added in v0.1.3
ApplyFileIncrement changes pages according to supplied change map file
func CleanupPrefetchDirectories ¶ added in v0.1.14
func ComputeDeletionSkipline ¶ added in v0.1.14
func ComputeDeletionSkipline(backups []BackupTime, target *Backup) (skipLine int, walSkipFileName string)
ComputeDeletionSkipline selects last backup and name of last necessary WAL
func Configure ¶
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 CreateFileWith ¶ added in v0.1.14
func CreateUploader ¶
func CreateUploader(svc s3iface.S3API, partsize, concurrency int) s3manageriface.UploaderAPI
CreateUploader returns an uploader with customizable concurrency and partsize.
func DecryptAndDecompressTar ¶ added in v0.1.14
func DecryptAndDecompressTar(writer io.Writer, readerMaker ReaderMaker, crypter Crypter) error
TODO : unit tests Ensures that file extension is valid. Any subsequent behavior depends on file type.
func ExtractAll ¶
func ExtractAll(tarInterpreter TarInterpreter, files []ReaderMaker) error
TODO : unit tests 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 ExtractBlockLocations ¶ added in v0.1.14
func ExtractBlockLocations(records []walparser.XLogRecord) []walparser.BlockLocation
func GetBackupPath ¶ added in v0.1.4
GetBackupPath gets path for basebackup in a bucket
func GetDeltaFilenameFor ¶ added in v0.1.14
func GetFileExtension ¶ added in v0.1.11
func GetFileRelativePath ¶ added in v0.1.14
func GetKeyRingId ¶ added in v0.1.3
func GetKeyRingId() string
GetKeyRingId extracts name of a key to use from env variable
func GetLatestBackupKey ¶ added in v0.1.14
func GetNextWalFilename ¶ added in v0.1.14
GetNextWalFilename computes name of next WAL segment
func GetPositionInDelta ¶ added in v0.1.14
func GetPrefetchLocations ¶ added in v0.1.14
func GetRelFileIdFrom ¶ added in v0.1.14
func GetRelFileNodeFrom ¶ added in v0.1.14
func GetRelFileNodeFrom(filePath string) (*walparser.RelFileNode, error)
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
func HandleBackupFetch(backupName string, folder *S3Folder, archiveDirectory string, mem bool) (lsn *uint64)
TODO : unit tests HandleBackupFetch is invoked to perform wal-g backup-fetch
func HandleBackupList ¶ added in v0.1.3
func HandleBackupList(folder *S3Folder)
TODO : unit tests HandleBackupList is invoked to perform wal-g backup-list
func HandleBackupPush ¶ added in v0.1.3
TODO : unit tests HandleBackupPush is invoked to perform a wal-g backup-push
func HandleDelete ¶ added in v0.1.3
TODO : unit tests HandleDelete is invoked to perform wal-g delete
func HandleWALFetch ¶ added in v0.1.3
TODO : unit tests HandleWALFetch is invoked to performa wal-g wal-fetch
func HandleWALPrefetch ¶ added in v0.1.3
TODO : unit tests HandleWALPrefetch is invoked by wal-fetch command to speed up database restoration
func HandleWALPush ¶ added in v0.1.3
TODO : unit tests HandleWALPush is invoked to perform wal-g wal-push
func IsAwsNotExist ¶ added in v0.1.14
func LookupConfigValue ¶ added in v0.1.14
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 PackFileTo ¶ added in v0.1.14
func ParseWALFilename ¶ added in v0.1.14
TODO : unit tests ParseWALFilename extracts numeric parts from WAL file name
func ReadIncrementFileHeader ¶ added in v0.1.14
func ReadIncrementalFile ¶ added in v0.1.14
func ReadLocationsFrom ¶ added in v0.1.14
func ReadLocationsFrom(reader io.Reader) ([]walparser.BlockLocation, error)
func ResolveSymlink ¶ added in v0.1.4
ResolveSymlink converts path to physical if it is symlink
func SelectRelFileBlocks ¶ added in v0.1.14
func ShouldPrefault ¶ added in v0.1.14
func ToPartFilename ¶ added in v0.1.14
func TryDownloadWALFile ¶ added in v0.1.14
func WriteLocationsTo ¶ added in v0.1.14
func WriteLocationsTo(writer io.Writer, locations []walparser.BlockLocation) error
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 ArchiveNonExistenceError ¶ added in v0.1.14
type ArchiveNonExistenceError struct {
// contains filtered or unexported fields
}
func (ArchiveNonExistenceError) Error ¶ added in v0.1.14
func (err ArchiveNonExistenceError) Error() string
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.
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
func GetGarbageBackupTimeSlicesFromPrefix ¶ added in v0.1.14
func GetGarbageBackupTimeSlicesFromPrefix(backups []*s3.CommonPrefix, nongarbage []BackupTime) []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 NewBgUploader ¶ added in v0.1.14
func NewBgUploader(walFilePath string, maxParallelWorkers int32, uploader *Uploader) *BgUploader
func (*BgUploader) Start ¶ added in v0.1.5
func (bgUploader *BgUploader) Start()
Start up checking what's inside archive_status
type BlockLocationReader ¶ added in v0.1.14
type BlockLocationReader struct {
// contains filtered or unexported fields
}
func NewBlockLocationReader ¶ added in v0.1.14
func NewBlockLocationReader(underlying io.Reader) *BlockLocationReader
func (*BlockLocationReader) ReadNextLocation ¶ added in v0.1.14
func (reader *BlockLocationReader) ReadNextLocation() (*walparser.BlockLocation, error)
ReadNextLocation returns any reader error wrapped with errors.Wrap
type BlockLocationWriter ¶ added in v0.1.14
func NewBlockLocationWriter ¶ added in v0.1.14
func NewBlockLocationWriter(underlying io.Writer) *BlockLocationWriter
func (*BlockLocationWriter) WriteLocation ¶ added in v0.1.14
func (locationWriter *BlockLocationWriter) WriteLocation(location walparser.BlockLocation) error
type BrotliCompressor ¶ added in v0.1.14
type BrotliCompressor struct{}
func (BrotliCompressor) FileExtension ¶ added in v0.1.14
func (compressor BrotliCompressor) FileExtension() string
func (BrotliCompressor) NewWriter ¶ added in v0.1.14
func (compressor BrotliCompressor) NewWriter(writer io.Writer) ReaderFromWriteCloser
type BrotliDecompressor ¶ added in v0.1.14
type BrotliDecompressor struct{}
func (BrotliDecompressor) Decompress ¶ added in v0.1.14
func (BrotliDecompressor) FileExtension ¶ added in v0.1.14
func (decompressor BrotliDecompressor) FileExtension() string
type BrotliReaderFromWriter ¶ added in v0.1.14
func NewBrotliReaderFromWriter ¶ added in v0.1.14
func NewBrotliReaderFromWriter(dst io.Writer) *BrotliReaderFromWriter
type Bundle ¶
type Bundle struct {
ArchiveDirectory string
TarSizeThreshold int64
Sentinel *Sentinel
TarBall TarBall
TarBallMaker TarBallMaker
Crypter OpenPGPCrypter
Timeline uint32
Replica bool
IncrementFromLsn *uint64
IncrementFromFiles BackupFileList
DeltaMap PagedFileDeltaMap
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 except for the last one will be at least TarSizeThreshold bytes. The Sentinel is used to ensure complete uploaded backups; in this case, pg_control is used as the sentinel.
func NewBundle ¶ added in v0.1.14
func NewBundle(archiveDirectory string, incrementFromLsn *uint64, incrementFromFiles BackupFileList) *Bundle
TODO: use DiskDataFolder
func (*Bundle) CheckSizeAndEnqueueBack ¶ added in v0.1.8
func (*Bundle) DownloadDeltaMap ¶ added in v0.1.14
func (*Bundle) EnqueueBack ¶ added in v0.1.8
func (*Bundle) FinishQueue ¶ added in v0.1.8
func (*Bundle) GetFileRelPath ¶ added in v0.1.14
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) HandleWalkedFSObject ¶ added in v0.1.14
TODO : unit tests HandleWalkedFSObject walks files provided by the passed in directory and creates compressed tar members labeled as `part_00i.tar.*`, where '*' is compressor file extension.
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.
func (*Bundle) NewTarBall ¶
NewTarBall starts writing new tarball
func (*Bundle) PrefaultWalkedFSObject ¶ added in v0.1.14
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)
TODO : unit tests 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) UploadLabelFiles ¶ added in v0.1.14
TODO : unit tests UploadLabelFiles creates the `backup_label` and `tablespace_map` files by stopping the backup and uploads them to S3.
func (*Bundle) UploadPgControl ¶ added in v0.1.14
TODO : unit tests UploadPgControl should only be called after the rest of the backup is successfully uploaded to S3.
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 (*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 DataFolder ¶ added in v0.1.14
type DataFolder interface {
// OpenReadonlyFile should return NoSuchFileError if it cannot find desired file
OpenReadonlyFile(filename string) (io.ReadCloser, error)
OpenWriteOnlyFile(filename string) (io.WriteCloser, error)
CleanFolder() error
}
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 {
Full bool
FindFull bool
Retain bool
Before bool
Target string
BeforeTime *time.Time
// 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 DeltaFile ¶ added in v0.1.14
type DeltaFile struct {
Locations []walparser.BlockLocation
WalParser *walparser.WalParser
}
func NewDeltaFile ¶ added in v0.1.14
type DeltaFileChanWriter ¶ added in v0.1.14
type DeltaFileChanWriter struct {
DeltaFile *DeltaFile
BlockLocationConsumer chan walparser.BlockLocation
}
func NewDeltaFileChanWriter ¶ added in v0.1.14
func NewDeltaFileChanWriter(deltaFile *DeltaFile) *DeltaFileChanWriter
func (*DeltaFileChanWriter) Consume ¶ added in v0.1.14
func (writer *DeltaFileChanWriter) Consume(waitGroup *sync.WaitGroup)
type DeltaFileManager ¶ added in v0.1.14
type DeltaFileManager struct {
PartFiles *LazyCache
DeltaFileWriters *LazyCache
CanceledDeltaFiles map[string]bool
// contains filtered or unexported fields
}
func NewDeltaFileManager ¶ added in v0.1.14
func NewDeltaFileManager(dataFolder DataFolder) *DeltaFileManager
func (*DeltaFileManager) CancelRecording ¶ added in v0.1.14
func (manager *DeltaFileManager) CancelRecording(walFilename string)
func (*DeltaFileManager) CombinePartFile ¶ added in v0.1.14
func (manager *DeltaFileManager) CombinePartFile(deltaFilename string, partFile *WalPartFile) error
func (*DeltaFileManager) FlushDeltaFiles ¶ added in v0.1.14
func (manager *DeltaFileManager) FlushDeltaFiles(uploader *Uploader, completedPartFiles map[string]bool)
func (*DeltaFileManager) FlushFiles ¶ added in v0.1.14
func (manager *DeltaFileManager) FlushFiles(uploader *Uploader)
func (*DeltaFileManager) FlushPartFiles ¶ added in v0.1.14
func (manager *DeltaFileManager) FlushPartFiles() (completedPartFiles map[string]bool)
func (*DeltaFileManager) GetBlockLocationConsumer ¶ added in v0.1.14
func (manager *DeltaFileManager) GetBlockLocationConsumer(deltaFilename string) (chan walparser.BlockLocation, error)
func (*DeltaFileManager) GetPartFile ¶ added in v0.1.14
func (manager *DeltaFileManager) GetPartFile(deltaFilename string) (*WalPartFile, error)
func (*DeltaFileManager) LoadDeltaFileWriter ¶ added in v0.1.14
func (manager *DeltaFileManager) LoadDeltaFileWriter(deltaFilename string) (deltaFileWriter *DeltaFileChanWriter, err error)
TODO : unit tests
func (*DeltaFileManager) LoadPartFile ¶ added in v0.1.14
func (manager *DeltaFileManager) LoadPartFile(partFilename string) (*WalPartFile, error)
TODO : unit tests
type DeltaFileWriterNotFoundError ¶ added in v0.1.14
type DeltaFileWriterNotFoundError struct {
// contains filtered or unexported fields
}
func (DeltaFileWriterNotFoundError) Error ¶ added in v0.1.14
func (err DeltaFileWriterNotFoundError) Error() string
type DiskDataFolder ¶ added in v0.1.14
type DiskDataFolder struct {
// contains filtered or unexported fields
}
func NewDiskDataFolder ¶ added in v0.1.14
func NewDiskDataFolder(folderPath string) (*DiskDataFolder, error)
func (*DiskDataFolder) CleanFolder ¶ added in v0.1.14
func (folder *DiskDataFolder) CleanFolder() error
func (*DiskDataFolder) OpenReadonlyFile ¶ added in v0.1.14
func (folder *DiskDataFolder) OpenReadonlyFile(filename string) (io.ReadCloser, error)
func (*DiskDataFolder) OpenWriteOnlyFile ¶ added in v0.1.14
func (folder *DiskDataFolder) OpenWriteOnlyFile(filename string) (io.WriteCloser, error)
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 (cleaner FileSystemCleaner) GetFiles(directory string) (files []string, err error)
TODO : unit tests GetFiles of a directory
func (FileSystemCleaner) Remove ¶ added in v0.1.3
func (cleaner 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 {
PagedFile ReadSeekCloser
FileSize int64
Lsn uint64
Next []byte
Blocks []uint32
}
IncrementalPageReader constructs difference map during initialization and than re-read file Diff map may consist of 1Gb/PostgresBlockSize elements == 512Kb
func (*IncrementalPageReader) AdvanceFileReader ¶ added in v0.1.3
func (pageReader *IncrementalPageReader) AdvanceFileReader() error
func (*IncrementalPageReader) Close ¶ added in v0.1.3
func (pageReader *IncrementalPageReader) Close() error
Close IncrementalPageReader
func (*IncrementalPageReader) DeltaBitmapInitialize ¶ added in v0.1.14
func (pageReader *IncrementalPageReader) DeltaBitmapInitialize(deltaBitmap *roaring.Bitmap)
func (*IncrementalPageReader) DrainMoreData ¶ added in v0.1.3
func (pageReader *IncrementalPageReader) DrainMoreData() (succeed bool, err error)
func (*IncrementalPageReader) FullScanInitialize ¶ added in v0.1.14
func (pageReader *IncrementalPageReader) FullScanInitialize() error
func (*IncrementalPageReader) Read ¶ added in v0.1.3
func (pageReader *IncrementalPageReader) Read(p []byte) (n int, err error)
func (*IncrementalPageReader) SelectNewValidPage ¶ added in v0.1.14
func (pageReader *IncrementalPageReader) SelectNewValidPage(pageBytes []byte, blockNo uint32) (valid bool)
SelectNewValidPage checks whether page is valid and if it so, then blockNo is appended to Blocks list
func (*IncrementalPageReader) WriteDiffMapToHeader ¶ added in v0.1.14
func (pageReader *IncrementalPageReader) WriteDiffMapToHeader(headerWriter io.Writer)
WriteDiffMapToHeader is currently used only with buffers, so we don't handle any writing errors
type InvalidBlockError ¶ added in v0.1.14
type InvalidBlockError struct {
// contains filtered or unexported fields
}
InvalidBlockError indicates that file contain invalid page and cannot be archived incrementally
func (*InvalidBlockError) Error ¶ added in v0.1.14
func (err *InvalidBlockError) Error() string
type LazyCache ¶ added in v0.1.14
type LazyCache struct {
// contains filtered or unexported fields
}
func NewLazyCache ¶ added in v0.1.14
func (*LazyCache) LoadExisting ¶ added in v0.1.14
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 Lz4ReaderFromWriter ¶ added in v0.1.14
func NewLz4ReaderFromWriter ¶ added in v0.1.14
func NewLz4ReaderFromWriter(dst io.Writer) *Lz4ReaderFromWriter
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 NOPTarBall ¶ added in v0.1.14
type NOPTarBall struct {
// contains filtered or unexported fields
}
NOPTarBall mocks a tarball. Used for testing purposes.
func (*NOPTarBall) AddSize ¶ added in v0.1.14
func (tarBall *NOPTarBall) AddSize(i int64)
func (*NOPTarBall) AwaitUploads ¶ added in v0.1.14
func (tarBall *NOPTarBall) AwaitUploads()
func (*NOPTarBall) CloseTar ¶ added in v0.1.14
func (tarBall *NOPTarBall) CloseTar() error
func (*NOPTarBall) Finish ¶ added in v0.1.14
func (tarBall *NOPTarBall) Finish(sentinelDto *S3TarBallSentinelDto) error
func (*NOPTarBall) SetUp ¶ added in v0.1.14
func (tarBall *NOPTarBall) SetUp(crypter Crypter, params ...string)
func (*NOPTarBall) Size ¶ added in v0.1.14
func (tarBall *NOPTarBall) Size() int64
func (*NOPTarBall) TarWriter ¶ added in v0.1.14
func (tarBall *NOPTarBall) TarWriter() *tar.Writer
type NOPTarBallMaker ¶ added in v0.1.14
type NOPTarBallMaker struct {
// contains filtered or unexported fields
}
NOPTarBallMaker creates a new NOPTarBall. Used for testing purposes.
func (*NOPTarBallMaker) Make ¶ added in v0.1.14
func (tarBallMaker *NOPTarBallMaker) Make(inheritState bool) TarBall
Make creates a new NOPTarBall.
type NamedReader ¶ added in v0.1.14
type NamedReaderImpl ¶ added in v0.1.14
func (*NamedReaderImpl) Name ¶ added in v0.1.14
func (reader *NamedReaderImpl) Name() string
type NoSuchFileError ¶ added in v0.1.14
type NoSuchFileError struct {
// contains filtered or unexported fields
}
func NewNoSuchFileError ¶ added in v0.1.14
func NewNoSuchFileError(filename string) *NoSuchFileError
func (NoSuchFileError) Error ¶ added in v0.1.14
func (err NoSuchFileError) Error() string
type NotWalFilenameError ¶ added in v0.1.14
type NotWalFilenameError struct {
// contains filtered or unexported fields
}
func (NotWalFilenameError) Error ¶ added in v0.1.14
func (err NotWalFilenameError) Error() string
type OpenPGPCrypter ¶ added in v0.1.3
type OpenPGPCrypter struct {
Configured bool
KeyRingId string
PubKey openpgp.EntityList
SecretKey openpgp.EntityList
}
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) IsArmed ¶ added in v0.1.14
func (crypter *OpenPGPCrypter) IsArmed() bool
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 PagedFileDeltaMap ¶ added in v0.1.14
type PagedFileDeltaMap map[walparser.RelFileNode]*roaring.Bitmap
func NewPagedFileDeltaMap ¶ added in v0.1.14
func NewPagedFileDeltaMap() PagedFileDeltaMap
func (*PagedFileDeltaMap) AddToDelta ¶ added in v0.1.14
func (deltaMap *PagedFileDeltaMap) AddToDelta(location walparser.BlockLocation)
func (*PagedFileDeltaMap) GetDeltaBitmapFor ¶ added in v0.1.14
func (deltaMap *PagedFileDeltaMap) GetDeltaBitmapFor(filePath string) (*roaring.Bitmap, error)
TODO : unit test no bitmap found
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 PostgresPageHeader ¶ added in v0.1.14
type PostgresPageHeader struct {
// contains filtered or unexported fields
}
func ParsePostgresPageHeader ¶ added in v0.1.14
func ParsePostgresPageHeader(reader io.Reader) (*PostgresPageHeader, error)
ParsePostgresPageHeader reads information from PostgreSQL page header. Exported for test reasons.
func (*PostgresPageHeader) IsNew ¶ added in v0.1.14
func (header *PostgresPageHeader) IsNew() bool
func (*PostgresPageHeader) IsValid ¶ added in v0.1.14
func (header *PostgresPageHeader) IsValid() bool
func (*PostgresPageHeader) Lsn ¶ added in v0.1.14
func (header *PostgresPageHeader) Lsn() uint64
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 ReadSeekCloser ¶ added in v0.1.14
type ReadSeekCloserImpl ¶ added in v0.1.14
type ReaderFromWriteCloser ¶ added in v0.1.11
type ReaderFromWriteCloser interface {
io.ReaderFrom
io.WriteCloser
}
type ReaderMaker ¶
type ReaderMaker interface {
Reader() (io.ReadCloser, error)
Path() string
}
ReaderMaker is the generic interface used by extract. It allows for ease of handling different file formats.
type S3Folder ¶ added in v0.1.14
type S3ReaderMaker ¶
S3ReaderMaker creates readers for downloading from S3
func NewS3ReaderMaker ¶ added in v0.1.14
func NewS3ReaderMaker(folder *S3Folder, key string) *S3ReaderMaker
func (*S3ReaderMaker) Path ¶
func (readerMaker *S3ReaderMaker) Path() 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 {
// 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) 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.
type S3TarBallMaker ¶
type S3TarBallMaker struct {
// contains filtered or unexported fields
}
S3TarBallMaker creates tarballs that are uploaded to S3.
func NewS3TarBallMaker ¶ added in v0.1.14
func NewS3TarBallMaker(backupName string, uploader *Uploader) *S3TarBallMaker
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 {
BackupStartLSN *uint64 `json:"LSN"`
IncrementFromLSN *uint64 `json:"DeltaFromLSN,omitempty"`
IncrementFrom *string `json:"DeltaFrom,omitempty"`
IncrementFullName *string `json:"DeltaFullName,omitempty"`
IncrementCount *int `json:"DeltaCount,omitempty"`
Files BackupFileList `json:"Files"`
PgVersion int `json:"PgVersion"`
BackupFinishLSN *uint64 `json:"FinishLSN"`
UserData interface{} `json:"UserData,omitempty"`
}
S3TarBallSentinelDto describes file structure of json sentinel
type TarBall ¶
type TarBall interface {
SetUp(crypter Crypter, args ...string)
CloseTar() error
Finish(sentinelDto *S3TarBallSentinelDto) error
Size() int64
AddSize(int64)
TarWriter() *tar.Writer
AwaitUploads()
}
A TarBall represents one tar file.
type TarBallMaker ¶
TarBallMaker is used to allow for flexible creation of different TarBalls.
func NewNopTarBallMaker ¶ added in v0.1.14
func NewNopTarBallMaker() TarBallMaker
type TarInterpreter ¶
TarInterpreter behaves differently for different file types.
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 Uploader ¶ added in v0.1.14
type Uploader struct {
SSEKMSKeyId string
StorageClass string
Success bool
// contains filtered or unexported fields
}
Uploader contains fields associated with uploading tarballs. Multiple tarballs can share one uploader. Must call CreateUploader() in 'configure.go'.
func NewUploader ¶ added in v0.1.14
func NewUploader( uploaderAPI s3manageriface.UploaderAPI, compressor Compressor, uploadingLocation *S3Folder, deltaDataFolder DataFolder, useWalDelta, verify bool, ) *Uploader
NewUploader creates a new tar uploader without the actual S3 uploader. CreateUploader() is used to configure byte size and concurrency streams for the uploader.
func (*Uploader) CreateUploadInput ¶ added in v0.1.14
CreateUploadInput creates a s3manager.UploadInput for a Uploader using the specified path and reader.
func (*Uploader) UploadFile ¶ added in v0.1.14
func (uploader *Uploader) UploadFile(file NamedReader) error
TODO : unit tests UploadFile compresses a file and uploads it.
func (*Uploader) UploadWalFile ¶ added in v0.1.14
func (uploader *Uploader) UploadWalFile(file NamedReader) error
TODO : unit tests
type WalDeltaRecorder ¶ added in v0.1.14
type WalDeltaRecorder struct {
// contains filtered or unexported fields
}
func NewWalDeltaRecorder ¶ added in v0.1.14
func NewWalDeltaRecorder(blockLocationConsumer chan walparser.BlockLocation) *WalDeltaRecorder
type WalDeltaRecordingReader ¶ added in v0.1.14
type WalDeltaRecordingReader struct {
PageReader walparser.WalPageReader
WalParser walparser.WalParser
PageDataLeftover []byte
Recorder *WalDeltaRecorder
// contains filtered or unexported fields
}
In case of recording error WalDeltaRecordingReader stops recording, but continues reading data correctly
func NewWalDeltaRecordingReader ¶ added in v0.1.14
func NewWalDeltaRecordingReader(walFileReader io.Reader, walFilename string, manager *DeltaFileManager) (*WalDeltaRecordingReader, error)
func (*WalDeltaRecordingReader) Close ¶ added in v0.1.14
func (reader *WalDeltaRecordingReader) Close() error
func (*WalDeltaRecordingReader) Read ¶ added in v0.1.14
func (reader *WalDeltaRecordingReader) Read(p []byte) (n int, err error)
func (*WalDeltaRecordingReader) RecordBlockLocationsFromPage ¶ added in v0.1.14
func (reader *WalDeltaRecordingReader) RecordBlockLocationsFromPage() error
type WalPart ¶ added in v0.1.14
type WalPart struct {
// contains filtered or unexported fields
}
func NewWalPart ¶ added in v0.1.14
func NewWalPart(dataType WalPartDataType, id uint8, data []byte) *WalPart
type WalPartDataType ¶ added in v0.1.14
type WalPartDataType uint8
const ( PreviousWalHeadType WalPartDataType = 0 WalTailType WalPartDataType = 1 WalHeadType WalPartDataType = 2 )
type WalPartFile ¶ added in v0.1.14
func LoadPartFile ¶ added in v0.1.14
func LoadPartFile(reader io.Reader) (*WalPartFile, error)
func NewWalPartFile ¶ added in v0.1.14
func NewWalPartFile() *WalPartFile
func (*WalPartFile) CombineRecords ¶ added in v0.1.14
func (partFile *WalPartFile) CombineRecords() ([]walparser.XLogRecord, error)
func (*WalPartFile) IsComplete ¶ added in v0.1.14
func (partFile *WalPartFile) IsComplete() bool
type WalPartRecorder ¶ added in v0.1.14
type WalPartRecorder struct {
// contains filtered or unexported fields
}
func NewWalPartRecorder ¶ added in v0.1.14
func NewWalPartRecorder(walFilename string, manager *DeltaFileManager) (*WalPartRecorder, error)
func (*WalPartRecorder) SaveNextWalHead ¶ added in v0.1.14
func (recorder *WalPartRecorder) SaveNextWalHead(head []byte) error
func (*WalPartRecorder) SavePreviousWalTail ¶ added in v0.1.14
func (recorder *WalPartRecorder) SavePreviousWalTail(tailData []byte) error
type WrongTypeError ¶ added in v0.1.14
type WrongTypeError struct {
// contains filtered or unexported fields
}
func (WrongTypeError) Error ¶ added in v0.1.14
func (err WrongTypeError) Error() string
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
- block_location_reader.go
- block_location_writer.go
- block_locations_util.go
- brotli_compressor.go
- brotli_decompressor.go
- brotli_reader_from_writer.go
- bundle.go
- cascade_closer.go
- cleaner.go
- commands.go
- compressing_pipe_writer.go
- compression.go
- config.go
- configure.go
- connect.go
- crypter.go
- crypto.go
- data_folder.go
- delay_write_closer.go
- delete.go
- delta_file.go
- delta_file_chan_writer.go
- delta_file_manager.go
- disk_data_folder.go
- errors.go
- extract.go
- file_system_cleaner.go
- incremental_page_reader.go
- io_utils.go
- lazy_cache.go
- lz4_compressor.go
- lz4_decompressor.go
- lz4_reader_from_writer.go
- lzma_compressor.go
- lzma_decompressor.go
- lzma_reader_from_writer.go
- lzo_decompressor.go
- lzo_disabled.go
- md5_reader.go
- named_reader.go
- nop_tarball.go
- open_pgp_crypter.go
- paged_file_delta_map.go
- pagefile.go
- postgres_page_header.go
- prefetch.go
- queryRunner.go
- reader_maker.go
- s3_folder.go
- s3_reader_maker.go
- s3_tar_ball.go
- s3_tar_ball_maker.go
- s3_tar_ball_sentinel_dto.go
- saver.go
- sentinel.go
- tar_ball.go
- tar_ball_maker.go
- tar_interpreter.go
- time_slice.go
- timeline.go
- until_eof_reader.go
- uploader.go
- utility.go
- wal_delta_recorder.go
- wal_delta_recording_reader.go
- wal_delta_util.go
- wal_part.go
- wal_part_file.go
- wal_part_recorder.go
- zstd_compressor.go
- zstd_decompressor.go
- zstd_reader_from_writer.go
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
wal-g
command
|
|
|
cmd/compress
command
|
|
|
cmd/delta
command
|
|
|
cmd/extract
command
|
|
|
cmd/generate
command
|
|