Documentation ¶
Index ¶
- Constants
- Variables
- func ApplyFileIncrement(fileName string, increment io.Reader) error
- func CleanupPrefetchDirectories(walFileName string, location string, cleaner Cleaner)
- func ComputeDeletionSkiplineAndPrintIntentions(backups []BackupTime, target *Backup) (skipLine int, walSkipFileName string)
- func Configure() (uploader *Uploader, destinationFolder StorageFolder, err error)
- func Connect() (*pgx.Conn, error)
- func CreateFileWith(filePath string, content io.Reader) error
- func CreateUploaderAPI(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 GetBaseFilesToUnwrap(backupFileStates BackupFileList, currentFilesToUnwrap map[string]bool) (map[string]bool, error)
- func GetDeltaFilenameFor(walFilename string) (string, error)
- func GetFileExtension(filePath string) string
- func GetFileRelativePath(fileAbsPath string, directoryPath string) string
- func GetKeyRingId() string
- 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 GetRestoredBackupFilesToUnwrap(sentinelDto BackupSentinelDto) map[string]bool
- func GetSentinelUserData() interface{}
- func HandleBackupFetch(backupName string, folder StorageFolder, dbDataDirectory string, mem bool)
- func HandleBackupList(folder StorageFolder)
- func HandleBackupPush(archiveDirectory string, uploader *Uploader)
- func HandleDelete(folder StorageFolder, args []string)
- func HandleWALFetch(folder StorageFolder, walFileName string, location string, ...)
- func HandleWALPrefetch(folder StorageFolder, walFileName string, location string, uploader *Uploader)
- func HandleWALPush(uploader *Uploader, walFilePath string)
- func IsDirectoryEmpty(directoryPath string) (bool, error)
- func JoinS3Path(elem ...string) string
- 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 OpenFileWithDir(filePath string) (*os.File, error)
- 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 ReaderMakersToFilePaths(readerMakers []ReaderMaker) []string
- 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 StorageFolder, walPath string) (walFileReader io.ReadCloser, exists bool, err error)
- func WriteLocationsTo(writer io.Writer, locations []walparser.BlockLocation) error
- type ArchiveNonExistenceError
- type Backup
- type BackupFileDescription
- type BackupFileList
- type BackupNonExistenceError
- type BackupSentinelDto
- 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 StorageFolder, 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 BytesPerWalSegmentError
- type CachedKey
- type CantDiscardWalDataError
- type CantOverwriteWalFileError
- type CascadeWriteCloser
- type Cleaner
- type CompressingPipeWriter
- type CompressingPipeWriterError
- type Compressor
- type Crypter
- type CrypterUseMischiefError
- 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 ExponentialRetrier
- type FSFolder
- func (folder *FSFolder) DeleteObjects(objectRelativePaths []string) error
- func (folder *FSFolder) EnsureExists() error
- func (folder *FSFolder) Exists(objectRelativePath string) (bool, error)
- func (folder *FSFolder) GetFilePath(objectRelativePath string) string
- func (folder *FSFolder) GetPath() string
- func (folder *FSFolder) GetSubFolder(subFolderRelativePath string) StorageFolder
- func (folder *FSFolder) ListFolder() (objects []StorageObject, subFolders []StorageFolder, err error)
- func (folder *FSFolder) PutObject(name string, content io.Reader) error
- func (folder *FSFolder) ReadObject(objectRelativePath string) (io.ReadCloser, error)
- type FSFolderError
- type FileStorageObject
- type FileSystemCleaner
- type FileTarInterpreter
- type GSFolder
- func (folder *GSFolder) DeleteObjects(objectRelativePaths []string) error
- func (folder *GSFolder) Exists(objectRelativePath string) (bool, error)
- func (folder *GSFolder) GetPath() string
- func (folder *GSFolder) GetSubFolder(subFolderRelativePath string) StorageFolder
- func (folder *GSFolder) ListFolder() (objects []StorageObject, subFolders []StorageFolder, err error)
- func (folder *GSFolder) PutObject(name string, content io.Reader) error
- func (folder *GSFolder) ReadObject(objectRelativePath string) (io.ReadCloser, error)
- type GSFolderError
- type GSStorageObject
- type GpgKeyExportError
- type IncorrectLogSegNoError
- 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 InvalidIncrementFileHeaderError
- type InvalidWalFileMagicError
- 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 *BackupSentinelDto) 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 NilWalParserError
- type NoBackupsFoundError
- type NoBitmapFoundError
- type NoFilesToExtractError
- type NoPostgresVersionError
- type NoSentinelUploadError
- type NoSuchFileError
- type NonEmptyDbDataDirectoryError
- type NotWalFilenameError
- type ObjectNotFoundError
- 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 PgControlNotFoundError
- 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
- func (folder *S3Folder) DeleteObjects(objectRelativePaths []string) error
- func (folder *S3Folder) Exists(objectRelativePath string) (bool, error)
- func (folder *S3Folder) GetPath() string
- func (folder *S3Folder) GetSubFolder(subFolderRelativePath string) StorageFolder
- func (folder *S3Folder) ListFolder() (objects []StorageObject, subFolders []StorageFolder, err error)
- func (folder *S3Folder) PutObject(name string, content io.Reader) error
- func (folder *S3Folder) ReadObject(objectRelativePath string) (io.ReadCloser, error)
- type S3StorageObject
- type S3Uploader
- type Saver
- type Sentinel
- type SseKmsIdNotSetError
- type StorageFolder
- type StorageObject
- type StorageReaderMaker
- type StorageTarBall
- func (tarBall *StorageTarBall) AddSize(i int64)
- func (tarBall *StorageTarBall) AwaitUploads()
- func (tarBall *StorageTarBall) CloseTar() error
- func (tarBall *StorageTarBall) Finish(sentinelDto *BackupSentinelDto) error
- func (tarBall *StorageTarBall) SetUp(crypter Crypter, names ...string)
- func (tarBall *StorageTarBall) Size() int64
- func (tarBall *StorageTarBall) TarWriter() *tar.Writer
- type StorageTarBallMaker
- type TarBall
- type TarBallMaker
- type TarInterpreter
- type TarSizeError
- type TimeSlice
- type UnexpectedTarDataError
- type UnknownCompressionMethodError
- type UnknownIncrementFileHeaderError
- type UnknownTableSpaceError
- type UnsetEnvVarError
- type UnsupportedFileTypeError
- type UnsupportedPostgresVersionError
- 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 ( PgControlPath = "/global/pg_control" LatestString = "LATEST" )
const ( DefaultTarSizeThreshold = int64((1 << 30) - 1) PgControl = "pg_control" BackupLabelFilename = "backup_label" TablespaceMapFilename = "tablespace_map" )
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) DefaultDataFolderPath = "/tmp" )
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" BaseBackupPath = "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 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 TarPartitionFolderName = "/tar_partitions/"
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, BrotliAlgorithmName}
var Compressors = map[string]Compressor{ Lz4AlgorithmName: Lz4Compressor{}, LzmaAlgorithmName: LzmaCompressor{}, BrotliAlgorithmName: BrotliCompressor{}, }
var Decompressors = []Decompressor{ Lz4Decompressor{}, BrotliDecompressor{}, LzmaDecompressor{}, ZstdDecompressor{}, }
var DiskLimiter *rate.Limiter
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 MaxExtractRetryWait = 5 * time.Minute
var MaxRetries = 15
MaxRetries limit upload and download retries during interaction with S3
var MinExtractRetryWait = time.Minute
var NetworkLimiter *rate.Limiter
var TerminalLocation = *walparser.NewBlockLocation(0, 0, 0, 0)
var UtilityFilePaths = map[string]bool{ PgControlPath: true, BackupLabelFilename: true, TablespaceMapFilename: true, }
var (
WalgConfig *map[string]string
)
Functions ¶
func ApplyFileIncrement ¶
ApplyFileIncrement changes pages according to supplied change map file
func ComputeDeletionSkiplineAndPrintIntentions ¶
func ComputeDeletionSkiplineAndPrintIntentions(backups []BackupTime, target *Backup) (skipLine int, walSkipFileName string)
ComputeDeletionSkiplineAndPrintIntentions selects last backup and name of last necessary WAL
func Configure ¶
func Configure() (uploader *Uploader, destinationFolder StorageFolder, err 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 CreateUploaderAPI ¶
func CreateUploaderAPI(svc s3iface.S3API, partsize, concurrency int) s3manageriface.UploaderAPI
CreateUploaderAPI returns an uploader with customizable concurrency and part size.
func DecryptAndDecompressTar ¶
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 ¶
func ExtractBlockLocations(records []walparser.XLogRecord) []walparser.BlockLocation
func GetBaseFilesToUnwrap ¶
func GetDeltaFilenameFor ¶
func GetFileRelativePath ¶
func GetKeyRingId ¶
func GetKeyRingId() string
GetKeyRingId extracts name of a key to use from env variable
func GetNextWalFilename ¶
GetNextWalFilename computes name of next WAL segment
func GetPositionInDelta ¶
func GetPrefetchLocations ¶
func GetRelFileIdFrom ¶
func GetRelFileNodeFrom ¶
func GetRelFileNodeFrom(filePath string) (*walparser.RelFileNode, error)
func GetRestoredBackupFilesToUnwrap ¶
func GetRestoredBackupFilesToUnwrap(sentinelDto BackupSentinelDto) map[string]bool
func GetSentinelUserData ¶
func GetSentinelUserData() interface{}
GetSentinelUserData tries to parse WALG_SENTINEL_USER_DATA env variable
func HandleBackupFetch ¶
func HandleBackupFetch(backupName string, folder StorageFolder, dbDataDirectory string, mem bool)
TODO : unit tests HandleBackupFetch is invoked to perform wal-g backup-fetch
func HandleBackupList ¶
func HandleBackupList(folder StorageFolder)
TODO : unit tests HandleBackupList is invoked to perform wal-g backup-list
func HandleBackupPush ¶
TODO : unit tests HandleBackupPush is invoked to perform a wal-g backup-push
func HandleDelete ¶
func HandleDelete(folder StorageFolder, args []string)
TODO : unit tests HandleDelete is invoked to perform wal-g delete
func HandleWALFetch ¶
func HandleWALFetch(folder StorageFolder, walFileName string, location string, triggerPrefetch bool)
TODO : unit tests HandleWALFetch is invoked to performa wal-g wal-fetch
func HandleWALPrefetch ¶
func HandleWALPrefetch(folder StorageFolder, walFileName string, location string, uploader *Uploader)
TODO : unit tests HandleWALPrefetch is invoked by wal-fetch command to speed up database restoration
func HandleWALPush ¶
TODO : unit tests HandleWALPush is invoked to perform wal-g wal-push
func JoinS3Path ¶
func LookupConfigValue ¶
func NewDiskLimitReader ¶
func NewDiskLimitReader(r io.ReadCloser) io.ReadCloser
NewDiskLimitReader returns a reader that is rate limited by disk limiter
func NewLzoReader ¶
func NewLzoReader(r io.Reader) (io.ReadCloser, error)
func NewLzoWriter ¶
func NewLzoWriter(w io.Writer) io.WriteCloser
func NewNetworkLimitReader ¶
func NewNetworkLimitReader(r io.ReadCloser) io.ReadCloser
NewNetworkLimitReader returns a reader that is rate limited by network limiter
func PackFileTo ¶
func ParseWALFilename ¶
TODO : unit tests ParseWALFilename extracts numeric parts from WAL file name
func ReadIncrementFileHeader ¶
func ReadIncrementalFile ¶
func ReadLocationsFrom ¶
func ReadLocationsFrom(reader io.Reader) ([]walparser.BlockLocation, error)
func ReaderMakersToFilePaths ¶
func ReaderMakersToFilePaths(readerMakers []ReaderMaker) []string
func ResolveSymlink ¶
ResolveSymlink converts path to physical if it is symlink
func SelectRelFileBlocks ¶
func ShouldPrefault ¶
func ToPartFilename ¶
func TryDownloadWALFile ¶
func TryDownloadWALFile(folder StorageFolder, walPath string) (walFileReader io.ReadCloser, exists bool, err error)
func WriteLocationsTo ¶
func WriteLocationsTo(writer io.Writer, locations []walparser.BlockLocation) error
Types ¶
type ArchiveNonExistenceError ¶
type ArchiveNonExistenceError struct {
// contains filtered or unexported fields
}
func NewArchiveNonExistenceError ¶
func NewArchiveNonExistenceError(archiveName string) ArchiveNonExistenceError
func (ArchiveNonExistenceError) Error ¶
func (err ArchiveNonExistenceError) Error() string
type Backup ¶
type Backup struct { BaseBackupFolder StorageFolder Name string }
Backup contains information about a valid backup generated and uploaded by WAL-G.
func GetBackupByName ¶
func GetBackupByName(backupName string, folder StorageFolder) (*Backup, error)
func NewBackup ¶
func NewBackup(baseBackupFolder StorageFolder, name string) *Backup
func (*Backup) CheckExistence ¶
CheckExistence checks that the specified backup exists.
func (*Backup) GetTarNames ¶
type BackupFileDescription ¶
type BackupFileDescription struct { IsIncremented bool // should never be both incremented and Skipped IsSkipped bool MTime time.Time }
func NewBackupFileDescription ¶
func NewBackupFileDescription(isIncremented, isSkipped bool, modTime time.Time) *BackupFileDescription
type BackupFileList ¶
type BackupFileList map[string]BackupFileDescription
type BackupNonExistenceError ¶
type BackupNonExistenceError struct {
// contains filtered or unexported fields
}
func NewBackupNonExistenceError ¶
func NewBackupNonExistenceError(backupName string) BackupNonExistenceError
func (BackupNonExistenceError) Error ¶
func (err BackupNonExistenceError) Error() string
type BackupSentinelDto ¶
type BackupSentinelDto 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"` }
BackupSentinelDto describes file structure of json sentinel
type BackupTime ¶
BackupTime is used to sort backups by latest modified time.
type BgUploader ¶
type BgUploader struct {
// contains filtered or unexported fields
}
BgUploader represents the state of concurrent WAL upload
func NewBgUploader ¶
func NewBgUploader(walFilePath string, maxParallelWorkers int32, uploader *Uploader) *BgUploader
func (*BgUploader) Start ¶
func (bgUploader *BgUploader) Start()
Start up checking what's inside archive_status
type BlockLocationReader ¶
type BlockLocationReader struct {
// contains filtered or unexported fields
}
func NewBlockLocationReader ¶
func NewBlockLocationReader(underlying io.Reader) *BlockLocationReader
func (*BlockLocationReader) ReadNextLocation ¶
func (reader *BlockLocationReader) ReadNextLocation() (*walparser.BlockLocation, error)
ReadNextLocation returns any reader error wrapped with errors.Wrap
type BlockLocationWriter ¶
func NewBlockLocationWriter ¶
func NewBlockLocationWriter(underlying io.Writer) *BlockLocationWriter
func (*BlockLocationWriter) WriteLocation ¶
func (locationWriter *BlockLocationWriter) WriteLocation(location walparser.BlockLocation) error
type BrotliCompressor ¶
type BrotliCompressor struct{}
func (BrotliCompressor) FileExtension ¶
func (compressor BrotliCompressor) FileExtension() string
func (BrotliCompressor) NewWriter ¶
func (compressor BrotliCompressor) NewWriter(writer io.Writer) ReaderFromWriteCloser
type BrotliDecompressor ¶
type BrotliDecompressor struct{}
func (BrotliDecompressor) Decompress ¶
func (BrotliDecompressor) FileExtension ¶
func (decompressor BrotliDecompressor) FileExtension() string
type BrotliReaderFromWriter ¶
func NewBrotliReaderFromWriter ¶
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 ¶
func NewBundle(archiveDirectory string, incrementFromLsn *uint64, incrementFromFiles BackupFileList) *Bundle
TODO: use DiskDataFolder
func (*Bundle) CheckSizeAndEnqueueBack ¶
func (*Bundle) DownloadDeltaMap ¶
func (bundle *Bundle) DownloadDeltaMap(folder StorageFolder, backupStartLSN uint64) error
func (*Bundle) EnqueueBack ¶
func (*Bundle) FinishQueue ¶
func (*Bundle) GetFileRelPath ¶
func (*Bundle) GetIncrementBaseFiles ¶
func (bundle *Bundle) GetIncrementBaseFiles() BackupFileList
GetIncrementBaseFiles returns list of Files from previous backup
func (*Bundle) GetIncrementBaseLsn ¶
GetIncrementBaseLsn returns LSN of previous backup
func (*Bundle) HandleWalkedFSObject ¶
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 ¶
TODO : unit tests
func (*Bundle) StartBackup ¶
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 ¶
func (bundle *Bundle) StartQueue()
func (*Bundle) UploadLabelFiles ¶
TODO : unit tests UploadLabelFiles creates the `backup_label` and `tablespace_map` files by stopping the backup and uploads them to S3.
func (*Bundle) UploadPgControl ¶
TODO : unit tests UploadPgControl should only be called after the rest of the backup is successfully uploaded to S3.
type BytesPerWalSegmentError ¶
type BytesPerWalSegmentError struct {
// contains filtered or unexported fields
}
func NewBytesPerWalSegmentError ¶
func NewBytesPerWalSegmentError() BytesPerWalSegmentError
func (BytesPerWalSegmentError) Error ¶
func (err BytesPerWalSegmentError) Error() string
type CantDiscardWalDataError ¶
type CantDiscardWalDataError struct {
// contains filtered or unexported fields
}
func NewCantDiscardWalDataError ¶
func NewCantDiscardWalDataError() CantDiscardWalDataError
func (CantDiscardWalDataError) Error ¶
func (err CantDiscardWalDataError) Error() string
type CantOverwriteWalFileError ¶
type CantOverwriteWalFileError struct {
// contains filtered or unexported fields
}
func NewCantOverwriteWalFileError ¶
func NewCantOverwriteWalFileError(walFilePath string) CantOverwriteWalFileError
func (CantOverwriteWalFileError) Error ¶
func (err CantOverwriteWalFileError) Error() string
type CascadeWriteCloser ¶
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 ¶
func (cascadeCloser *CascadeWriteCloser) Close() error
Close returns the first encountered error from closing main or underlying writer.
type Cleaner ¶
Cleaner interface serves to separate file system logic from prefetch clean logic to make it testable
type CompressingPipeWriter ¶
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 ¶
func (pipeWriter *CompressingPipeWriter) Compress(crypter Crypter)
Compress compresses input to a pipe reader. Output must be used or pipe will block.
type CompressingPipeWriterError ¶
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 NewCompressingPipeWriterError ¶
func NewCompressingPipeWriterError(reason string) CompressingPipeWriterError
func (CompressingPipeWriterError) Error ¶
func (err CompressingPipeWriterError) Error() string
type Compressor ¶
type Compressor interface { NewWriter(writer io.Writer) ReaderFromWriteCloser FileExtension() string }
type Crypter ¶
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 CrypterUseMischiefError ¶
type CrypterUseMischiefError struct {
// contains filtered or unexported fields
}
CrypterUseMischiefError happens when crypter is used before initialization
func NewCrypterUseMischiefError ¶
func NewCrypterUseMischiefError() CrypterUseMischiefError
func (CrypterUseMischiefError) Error ¶
func (err CrypterUseMischiefError) Error() string
type DataFolder ¶
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 ¶
type DelayWriteCloser ¶
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 ¶
func (delayWriteCloser *DelayWriteCloser) Close() error
Close DelayWriteCloser
type DeleteCommandArguments ¶
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 ¶
func ParseDeleteArguments(args []string, fallBackFunc func()) (result DeleteCommandArguments)
ParseDeleteArguments interprets arguments for delete command. TODO: use flags or cobra
type DeltaFile ¶
type DeltaFile struct { Locations []walparser.BlockLocation WalParser *walparser.WalParser }
type DeltaFileChanWriter ¶
type DeltaFileChanWriter struct { DeltaFile *DeltaFile BlockLocationConsumer chan walparser.BlockLocation }
func NewDeltaFileChanWriter ¶
func NewDeltaFileChanWriter(deltaFile *DeltaFile) *DeltaFileChanWriter
func (*DeltaFileChanWriter) Consume ¶
func (writer *DeltaFileChanWriter) Consume(waitGroup *sync.WaitGroup)
type DeltaFileManager ¶
type DeltaFileManager struct { PartFiles *LazyCache DeltaFileWriters *LazyCache CanceledDeltaFiles map[string]bool // contains filtered or unexported fields }
func NewDeltaFileManager ¶
func NewDeltaFileManager(dataFolder DataFolder) *DeltaFileManager
func (*DeltaFileManager) CancelRecording ¶
func (manager *DeltaFileManager) CancelRecording(walFilename string)
func (*DeltaFileManager) CombinePartFile ¶
func (manager *DeltaFileManager) CombinePartFile(deltaFilename string, partFile *WalPartFile) error
func (*DeltaFileManager) FlushDeltaFiles ¶
func (manager *DeltaFileManager) FlushDeltaFiles(uploader *Uploader, completedPartFiles map[string]bool)
func (*DeltaFileManager) FlushFiles ¶
func (manager *DeltaFileManager) FlushFiles(uploader *Uploader)
func (*DeltaFileManager) FlushPartFiles ¶
func (manager *DeltaFileManager) FlushPartFiles() (completedPartFiles map[string]bool)
func (*DeltaFileManager) GetBlockLocationConsumer ¶
func (manager *DeltaFileManager) GetBlockLocationConsumer(deltaFilename string) (chan walparser.BlockLocation, error)
func (*DeltaFileManager) GetPartFile ¶
func (manager *DeltaFileManager) GetPartFile(deltaFilename string) (*WalPartFile, error)
func (*DeltaFileManager) LoadDeltaFileWriter ¶
func (manager *DeltaFileManager) LoadDeltaFileWriter(deltaFilename string) (deltaFileWriter *DeltaFileChanWriter, err error)
TODO : unit tests
func (*DeltaFileManager) LoadPartFile ¶
func (manager *DeltaFileManager) LoadPartFile(partFilename string) (*WalPartFile, error)
TODO : unit tests
type DeltaFileWriterNotFoundError ¶
type DeltaFileWriterNotFoundError struct {
// contains filtered or unexported fields
}
func NewDeltaFileWriterNotFoundError ¶
func NewDeltaFileWriterNotFoundError(filename string) DeltaFileWriterNotFoundError
func (DeltaFileWriterNotFoundError) Error ¶
func (err DeltaFileWriterNotFoundError) Error() string
type DiskDataFolder ¶
type DiskDataFolder struct {
// contains filtered or unexported fields
}
func NewDiskDataFolder ¶
func NewDiskDataFolder(folderPath string) (*DiskDataFolder, error)
func (*DiskDataFolder) CleanFolder ¶
func (folder *DiskDataFolder) CleanFolder() error
func (*DiskDataFolder) OpenReadonlyFile ¶
func (folder *DiskDataFolder) OpenReadonlyFile(filename string) (io.ReadCloser, error)
func (*DiskDataFolder) OpenWriteOnlyFile ¶
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 ExponentialRetrier ¶
type ExponentialRetrier struct {
// contains filtered or unexported fields
}
func NewExponentialRetrier ¶
func NewExponentialRetrier(startSleepDuration, sleepDurationBound time.Duration) *ExponentialRetrier
type FSFolder ¶
type FSFolder struct {
// contains filtered or unexported fields
}
FSFolder represents folder of file system
func NewFSFolder ¶
func (*FSFolder) DeleteObjects ¶
func (*FSFolder) EnsureExists ¶
func (*FSFolder) GetFilePath ¶
func (*FSFolder) GetSubFolder ¶
func (folder *FSFolder) GetSubFolder(subFolderRelativePath string) StorageFolder
func (*FSFolder) ListFolder ¶
func (folder *FSFolder) ListFolder() (objects []StorageObject, subFolders []StorageFolder, err error)
func (*FSFolder) ReadObject ¶
func (folder *FSFolder) ReadObject(objectRelativePath string) (io.ReadCloser, error)
type FSFolderError ¶
type FSFolderError struct {
// contains filtered or unexported fields
}
func NewFSFolderError ¶
func NewFSFolderError(err error, format string, args ...interface{}) FSFolderError
func (FSFolderError) Error ¶
func (err FSFolderError) Error() string
type FileStorageObject ¶
func (FileStorageObject) GetLastModified ¶
func (object FileStorageObject) GetLastModified() time.Time
func (FileStorageObject) GetName ¶
func (object FileStorageObject) GetName() string
type FileSystemCleaner ¶
type FileSystemCleaner struct{}
FileSystemCleaner actually performs it's functions on file system
type FileTarInterpreter ¶
type FileTarInterpreter struct { DBDataDirectory string Sentinel BackupSentinelDto FilesToUnwrap map[string]bool }
FileTarInterpreter extracts input to disk.
func NewFileTarInterpreter ¶
func NewFileTarInterpreter(dbDataDirectory string, sentinel BackupSentinelDto, filesToUnwrap map[string]bool) *FileTarInterpreter
func (*FileTarInterpreter) Interpret ¶
func (tarInterpreter *FileTarInterpreter) Interpret(fileReader io.Reader, fileInfo *tar.Header) error
TODO : unit tests Interpret extracts a tar file to disk and creates needed directories. Returns the first error encountered. Calls fsync after each file is written successfully.
type GSFolder ¶
type GSFolder struct {
// contains filtered or unexported fields
}
GSFolder represents folder in GCP
func NewGSFolder ¶
func NewGSFolder(bucket *storage.BucketHandle, path string) *GSFolder
func (*GSFolder) DeleteObjects ¶
func (*GSFolder) GetSubFolder ¶
func (folder *GSFolder) GetSubFolder(subFolderRelativePath string) StorageFolder
func (*GSFolder) ListFolder ¶
func (folder *GSFolder) ListFolder() (objects []StorageObject, subFolders []StorageFolder, err error)
func (*GSFolder) ReadObject ¶
func (folder *GSFolder) ReadObject(objectRelativePath string) (io.ReadCloser, error)
type GSFolderError ¶
type GSFolderError struct {
// contains filtered or unexported fields
}
func NewGSFolderError ¶
func NewGSFolderError(err error, format string, args ...interface{}) GSFolderError
func (GSFolderError) Error ¶
func (err GSFolderError) Error() string
type GSStorageObject ¶
type GSStorageObject struct {
// contains filtered or unexported fields
}
func (*GSStorageObject) GetLastModified ¶
func (object *GSStorageObject) GetLastModified() time.Time
func (*GSStorageObject) GetName ¶
func (object *GSStorageObject) GetName() string
type GpgKeyExportError ¶
type GpgKeyExportError struct {
// contains filtered or unexported fields
}
func NewGpgKeyExportError ¶
func NewGpgKeyExportError(text string) GpgKeyExportError
func (GpgKeyExportError) Error ¶
func (err GpgKeyExportError) Error() string
type IncorrectLogSegNoError ¶
type IncorrectLogSegNoError struct {
// contains filtered or unexported fields
}
func NewIncorrectLogSegNoError ¶
func NewIncorrectLogSegNoError(name string) IncorrectLogSegNoError
func (IncorrectLogSegNoError) Error ¶
func (err IncorrectLogSegNoError) Error() string
type IncrementalPageReader ¶
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 ¶
func (pageReader *IncrementalPageReader) AdvanceFileReader() error
func (*IncrementalPageReader) Close ¶
func (pageReader *IncrementalPageReader) Close() error
Close IncrementalPageReader
func (*IncrementalPageReader) DeltaBitmapInitialize ¶
func (pageReader *IncrementalPageReader) DeltaBitmapInitialize(deltaBitmap *roaring.Bitmap)
func (*IncrementalPageReader) DrainMoreData ¶
func (pageReader *IncrementalPageReader) DrainMoreData() (succeed bool, err error)
func (*IncrementalPageReader) FullScanInitialize ¶
func (pageReader *IncrementalPageReader) FullScanInitialize() error
func (*IncrementalPageReader) Read ¶
func (pageReader *IncrementalPageReader) Read(p []byte) (n int, err error)
func (*IncrementalPageReader) SelectNewValidPage ¶
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 ¶
func (pageReader *IncrementalPageReader) WriteDiffMapToHeader(headerWriter io.Writer)
WriteDiffMapToHeader is currently used only with buffers, so we don't handle any writing errors
type InvalidBlockError ¶
type InvalidBlockError struct {
// contains filtered or unexported fields
}
InvalidBlockError indicates that file contain invalid page and cannot be archived incrementally
func NewInvalidBlockError ¶
func NewInvalidBlockError(blockNo uint32) InvalidBlockError
func (InvalidBlockError) Error ¶
func (err InvalidBlockError) Error() string
type InvalidIncrementFileHeaderError ¶
type InvalidIncrementFileHeaderError struct {
// contains filtered or unexported fields
}
func NewInvalidIncrementFileHeaderError ¶
func NewInvalidIncrementFileHeaderError() InvalidIncrementFileHeaderError
func (InvalidIncrementFileHeaderError) Error ¶
func (err InvalidIncrementFileHeaderError) Error() string
type InvalidWalFileMagicError ¶
type InvalidWalFileMagicError struct {
// contains filtered or unexported fields
}
func NewInvalidWalFileMagicError ¶
func NewInvalidWalFileMagicError() InvalidWalFileMagicError
func (InvalidWalFileMagicError) Error ¶
func (err InvalidWalFileMagicError) Error() string
type LazyCache ¶
type LazyCache struct {
// contains filtered or unexported fields
}
func NewLazyCache ¶
func (*LazyCache) LoadExisting ¶
type LimitedReader ¶
type LimitedReader struct {
// contains filtered or unexported fields
}
func (*LimitedReader) Close ¶
func (r *LimitedReader) Close() error
type Lz4Compressor ¶
type Lz4Compressor struct{}
func (Lz4Compressor) FileExtension ¶
func (compressor Lz4Compressor) FileExtension() string
func (Lz4Compressor) NewWriter ¶
func (compressor Lz4Compressor) NewWriter(writer io.Writer) ReaderFromWriteCloser
type Lz4Decompressor ¶
type Lz4Decompressor struct{}
func (Lz4Decompressor) Decompress ¶
func (Lz4Decompressor) FileExtension ¶
func (decompressor Lz4Decompressor) FileExtension() string
type Lz4ReaderFromWriter ¶
func NewLz4ReaderFromWriter ¶
func NewLz4ReaderFromWriter(dst io.Writer) *Lz4ReaderFromWriter
type LzmaCompressor ¶
type LzmaCompressor struct{}
func (LzmaCompressor) FileExtension ¶
func (compressor LzmaCompressor) FileExtension() string
func (LzmaCompressor) NewWriter ¶
func (compressor LzmaCompressor) NewWriter(writer io.Writer) ReaderFromWriteCloser
type LzmaDecompressor ¶
type LzmaDecompressor struct{}
func (LzmaDecompressor) Decompress ¶
func (LzmaDecompressor) FileExtension ¶
func (decompressor LzmaDecompressor) FileExtension() string
type LzmaReaderFromWriter ¶
func NewLzmaReaderFromWriter ¶
func NewLzmaReaderFromWriter(dst io.Writer) (*LzmaReaderFromWriter, error)
type LzoDecompressor ¶
type LzoDecompressor struct{}
func (LzoDecompressor) Decompress ¶
func (LzoDecompressor) FileExtension ¶
func (decompressor LzoDecompressor) FileExtension() string
type NOPTarBall ¶
type NOPTarBall struct {
// contains filtered or unexported fields
}
NOPTarBall mocks a tarball. Used for testing purposes.
func (*NOPTarBall) AddSize ¶
func (tarBall *NOPTarBall) AddSize(i int64)
func (*NOPTarBall) AwaitUploads ¶
func (tarBall *NOPTarBall) AwaitUploads()
func (*NOPTarBall) CloseTar ¶
func (tarBall *NOPTarBall) CloseTar() error
func (*NOPTarBall) Finish ¶
func (tarBall *NOPTarBall) Finish(sentinelDto *BackupSentinelDto) error
func (*NOPTarBall) SetUp ¶
func (tarBall *NOPTarBall) SetUp(crypter Crypter, params ...string)
func (*NOPTarBall) Size ¶
func (tarBall *NOPTarBall) Size() int64
func (*NOPTarBall) TarWriter ¶
func (tarBall *NOPTarBall) TarWriter() *tar.Writer
type NOPTarBallMaker ¶
type NOPTarBallMaker struct {
// contains filtered or unexported fields
}
NOPTarBallMaker creates a new NOPTarBall. Used for testing purposes.
func (*NOPTarBallMaker) Make ¶
func (tarBallMaker *NOPTarBallMaker) Make(inheritState bool) TarBall
Make creates a new NOPTarBall.
type NamedReader ¶
type NamedReaderImpl ¶
func (*NamedReaderImpl) Name ¶
func (reader *NamedReaderImpl) Name() string
type NilWalParserError ¶
type NilWalParserError struct {
// contains filtered or unexported fields
}
func NewNilWalParserError ¶
func NewNilWalParserError() NilWalParserError
func (NilWalParserError) Error ¶
func (err NilWalParserError) Error() string
type NoBackupsFoundError ¶
type NoBackupsFoundError struct {
// contains filtered or unexported fields
}
func NewNoBackupsFoundError ¶
func NewNoBackupsFoundError() NoBackupsFoundError
func (NoBackupsFoundError) Error ¶
func (err NoBackupsFoundError) Error() string
type NoBitmapFoundError ¶
type NoBitmapFoundError struct {
// contains filtered or unexported fields
}
func NewNoBitmapFoundError ¶
func NewNoBitmapFoundError() NoBitmapFoundError
func (NoBitmapFoundError) Error ¶
func (err NoBitmapFoundError) Error() string
type NoFilesToExtractError ¶
type NoFilesToExtractError struct {
// contains filtered or unexported fields
}
func NewNoFilesToExtractError ¶
func NewNoFilesToExtractError() NoFilesToExtractError
func (NoFilesToExtractError) Error ¶
func (err NoFilesToExtractError) Error() string
type NoPostgresVersionError ¶
type NoPostgresVersionError struct {
// contains filtered or unexported fields
}
func NewNoPostgresVersionError ¶
func NewNoPostgresVersionError() NoPostgresVersionError
func (NoPostgresVersionError) Error ¶
func (err NoPostgresVersionError) Error() string
type NoSentinelUploadError ¶
type NoSentinelUploadError struct {
// contains filtered or unexported fields
}
func NewNoSentinelUploadError ¶
func NewNoSentinelUploadError() NoSentinelUploadError
func (NoSentinelUploadError) Error ¶
func (err NoSentinelUploadError) Error() string
type NoSuchFileError ¶
type NoSuchFileError struct {
// contains filtered or unexported fields
}
func NewNoSuchFileError ¶
func NewNoSuchFileError(filename string) NoSuchFileError
func (NoSuchFileError) Error ¶
func (err NoSuchFileError) Error() string
type NonEmptyDbDataDirectoryError ¶
type NonEmptyDbDataDirectoryError struct {
// contains filtered or unexported fields
}
func NewNonEmptyDbDataDirectoryError ¶
func NewNonEmptyDbDataDirectoryError(dbDataDirectory string) NonEmptyDbDataDirectoryError
func (NonEmptyDbDataDirectoryError) Error ¶
func (err NonEmptyDbDataDirectoryError) Error() string
type NotWalFilenameError ¶
type NotWalFilenameError struct {
// contains filtered or unexported fields
}
func NewNotWalFilenameError ¶
func NewNotWalFilenameError(filename string) NotWalFilenameError
func (NotWalFilenameError) Error ¶
func (err NotWalFilenameError) Error() string
type ObjectNotFoundError ¶
type ObjectNotFoundError struct {
// contains filtered or unexported fields
}
func NewObjectNotFoundError ¶
func NewObjectNotFoundError(path string) ObjectNotFoundError
func (ObjectNotFoundError) Error ¶
func (err ObjectNotFoundError) Error() string
type OpenPGPCrypter ¶
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 ¶
func (crypter *OpenPGPCrypter) ConfigureGPGCrypter()
ConfigureGPGCrypter is OpenPGPCrypter internal initialization
func (*OpenPGPCrypter) Decrypt ¶
func (crypter *OpenPGPCrypter) Decrypt(reader io.ReadCloser) (io.Reader, error)
Decrypt creates decrypted reader from ordinary reader
func (*OpenPGPCrypter) Encrypt ¶
func (crypter *OpenPGPCrypter) Encrypt(writer io.WriteCloser) (io.WriteCloser, error)
Encrypt creates encryption writer from ordinary writer
func (*OpenPGPCrypter) IsArmed ¶
func (crypter *OpenPGPCrypter) IsArmed() bool
func (*OpenPGPCrypter) IsUsed ¶
func (crypter *OpenPGPCrypter) IsUsed() bool
IsUsed is to check necessity of Crypter use Must be called prior to any other crypter call
type PagedFileDeltaMap ¶
type PagedFileDeltaMap map[walparser.RelFileNode]*roaring.Bitmap
func NewPagedFileDeltaMap ¶
func NewPagedFileDeltaMap() PagedFileDeltaMap
func (*PagedFileDeltaMap) AddToDelta ¶
func (deltaMap *PagedFileDeltaMap) AddToDelta(location walparser.BlockLocation)
func (*PagedFileDeltaMap) GetDeltaBitmapFor ¶
func (deltaMap *PagedFileDeltaMap) GetDeltaBitmapFor(filePath string) (*roaring.Bitmap, error)
TODO : unit test no bitmap found
type PgControlNotFoundError ¶
type PgControlNotFoundError struct {
// contains filtered or unexported fields
}
func NewPgControlNotFoundError ¶
func NewPgControlNotFoundError() PgControlNotFoundError
func (PgControlNotFoundError) Error ¶
func (err PgControlNotFoundError) Error() string
type PgQueryRunner ¶
type PgQueryRunner struct { Version int // contains filtered or unexported fields }
PgQueryRunner is implementation for controlling PostgreSQL 9.0+
func NewPgQueryRunner ¶
func NewPgQueryRunner(conn *pgx.Conn) (*PgQueryRunner, error)
NewPgQueryRunner builds QueryRunner from available connection
func (*PgQueryRunner) BuildGetVersion ¶
func (queryRunner *PgQueryRunner) BuildGetVersion() string
BuildGetVersion formats a query to retrieve PostgreSQL numeric version
func (*PgQueryRunner) BuildStartBackup ¶
func (queryRunner *PgQueryRunner) BuildStartBackup() (string, error)
BuildStartBackup formats a query that starts backup according to server features and version
func (*PgQueryRunner) BuildStopBackup ¶
func (queryRunner *PgQueryRunner) BuildStopBackup() (string, error)
BuildStopBackup formats a query that stops backup according to server features and version
func (*PgQueryRunner) StartBackup ¶
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 ¶
func (queryRunner *PgQueryRunner) StopBackup() (label string, offsetMap string, lsnStr string, err error)
StopBackup informs the database that copy is over
type PostgresPageHeader ¶
type PostgresPageHeader struct {
// contains filtered or unexported fields
}
func ParsePostgresPageHeader ¶
func ParsePostgresPageHeader(reader io.Reader) (*PostgresPageHeader, error)
ParsePostgresPageHeader reads information from PostgreSQL page header. Exported for test reasons.
func (*PostgresPageHeader) IsNew ¶
func (header *PostgresPageHeader) IsNew() bool
func (*PostgresPageHeader) IsValid ¶
func (header *PostgresPageHeader) IsValid() bool
func (*PostgresPageHeader) Lsn ¶
func (header *PostgresPageHeader) Lsn() uint64
type QueryRunner ¶
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 ¶
ReadCascadeCloser composes io.ReadCloser from two parts
type ReaderFromWriteCloser ¶
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 ¶
type S3Folder struct { S3API s3iface.S3API Bucket *string Path string // contains filtered or unexported fields }
func NewS3Folder ¶
func NewS3Folder(uploader S3Uploader, s3API s3iface.S3API, bucket, path string) *S3Folder
func (*S3Folder) DeleteObjects ¶
func (*S3Folder) GetSubFolder ¶
func (folder *S3Folder) GetSubFolder(subFolderRelativePath string) StorageFolder
func (*S3Folder) ListFolder ¶
func (folder *S3Folder) ListFolder() (objects []StorageObject, subFolders []StorageFolder, err error)
func (*S3Folder) ReadObject ¶
func (folder *S3Folder) ReadObject(objectRelativePath string) (io.ReadCloser, error)
type S3StorageObject ¶
func NewS3StorageObject ¶
func NewS3StorageObject(object *s3.Object) *S3StorageObject
func (*S3StorageObject) GetLastModified ¶
func (object *S3StorageObject) GetLastModified() time.Time
func (*S3StorageObject) GetName ¶
func (object *S3StorageObject) GetName() string
type S3Uploader ¶
type S3Uploader struct { SSEKMSKeyId string StorageClass string // contains filtered or unexported fields }
func NewS3Uploader ¶
func NewS3Uploader(uploaderAPI s3manageriface.UploaderAPI, serverSideEncryption, sseKmsKeyId, storageClass string) *S3Uploader
type SseKmsIdNotSetError ¶
type SseKmsIdNotSetError struct {
// contains filtered or unexported fields
}
func NewSseKmsIdNotSetError ¶
func NewSseKmsIdNotSetError() SseKmsIdNotSetError
func (SseKmsIdNotSetError) Error ¶
func (err SseKmsIdNotSetError) Error() string
type StorageFolder ¶
type StorageFolder interface { // Path should always ends with '/' GetPath() string // Should return objects with relative paths ListFolder() (objects []StorageObject, subFolders []StorageFolder, err error) // Delete object, if exists DeleteObjects(objectRelativePaths []string) error Exists(objectRelativePath string) (bool, error) // Returns handle to subfolder. Does not have to instantiate subfolder in any material form GetSubFolder(subFolderRelativePath string) StorageFolder // Should return ObjectNotFoundError in case, there is no such object ReadObject(objectRelativePath string) (io.ReadCloser, error) PutObject(name string, content io.Reader) error }
func ConfigureFSFolder ¶
func ConfigureFSFolder(path string) (StorageFolder, error)
func ConfigureGSFolder ¶
func ConfigureGSFolder(prefix string) (StorageFolder, error)
type StorageObject ¶
type StorageReaderMaker ¶
type StorageReaderMaker struct { Folder StorageFolder RelativePath string }
StorageReaderMaker creates readers for downloading from storage
func NewStorageReaderMaker ¶
func NewStorageReaderMaker(folder StorageFolder, relativePath string) *StorageReaderMaker
func (*StorageReaderMaker) Path ¶
func (readerMaker *StorageReaderMaker) Path() string
func (*StorageReaderMaker) Reader ¶
func (readerMaker *StorageReaderMaker) Reader() (io.ReadCloser, error)
type StorageTarBall ¶
type StorageTarBall struct {
// contains filtered or unexported fields
}
StorageTarBall represents a tar file that is going to be uploaded to storage.
func (*StorageTarBall) AddSize ¶
func (tarBall *StorageTarBall) AddSize(i int64)
AddSize to total Size
func (*StorageTarBall) AwaitUploads ¶
func (tarBall *StorageTarBall) AwaitUploads()
func (*StorageTarBall) CloseTar ¶
func (tarBall *StorageTarBall) CloseTar() error
CloseTar closes the tar writer, flushing any unwritten data to the underlying writer before also closing the underlying writer.
func (*StorageTarBall) Finish ¶
func (tarBall *StorageTarBall) Finish(sentinelDto *BackupSentinelDto) 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 storage. an alert is given with the corresponding error.
func (*StorageTarBall) SetUp ¶
func (tarBall *StorageTarBall) SetUp(crypter Crypter, names ...string)
SetUp creates a new tar writer and starts upload to storage. 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 (*StorageTarBall) Size ¶
func (tarBall *StorageTarBall) Size() int64
Size accumulated in this tarball
func (*StorageTarBall) TarWriter ¶
func (tarBall *StorageTarBall) TarWriter() *tar.Writer
type StorageTarBallMaker ¶
type StorageTarBallMaker struct {
// contains filtered or unexported fields
}
StorageTarBallMaker creates tarballs that are uploaded to storage.
func NewStorageTarBallMaker ¶
func NewStorageTarBallMaker(backupName string, uploader *Uploader) *StorageTarBallMaker
func (*StorageTarBallMaker) Make ¶
func (tarBallMaker *StorageTarBallMaker) Make(dedicatedUploader bool) TarBall
Make returns a tarball with required storage fields.
type TarBall ¶
type TarBall interface { SetUp(crypter Crypter, args ...string) CloseTar() error Finish(sentinelDto *BackupSentinelDto) 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 ¶
func NewNopTarBallMaker() TarBallMaker
type TarInterpreter ¶
TarInterpreter behaves differently for different file types.
type TarSizeError ¶
type TarSizeError struct {
// contains filtered or unexported fields
}
func NewTarSizeError ¶
func NewTarSizeError(packedFileSize, expectedSize int64) TarSizeError
func (TarSizeError) Error ¶
func (err TarSizeError) Error() string
type TimeSlice ¶
type TimeSlice []BackupTime
TimeSlice represents a backup and its last modified time.
type UnexpectedTarDataError ¶
type UnexpectedTarDataError struct {
// contains filtered or unexported fields
}
func NewUnexpectedTarDataError ¶
func NewUnexpectedTarDataError() UnexpectedTarDataError
func (UnexpectedTarDataError) Error ¶
func (err UnexpectedTarDataError) Error() string
type UnknownCompressionMethodError ¶
type UnknownCompressionMethodError struct {
// contains filtered or unexported fields
}
func NewUnknownCompressionMethodError ¶
func NewUnknownCompressionMethodError() UnknownCompressionMethodError
func (UnknownCompressionMethodError) Error ¶
func (err UnknownCompressionMethodError) Error() string
type UnknownIncrementFileHeaderError ¶
type UnknownIncrementFileHeaderError struct {
// contains filtered or unexported fields
}
func NewUnknownIncrementFileHeaderError ¶
func NewUnknownIncrementFileHeaderError() UnknownIncrementFileHeaderError
func (UnknownIncrementFileHeaderError) Error ¶
func (err UnknownIncrementFileHeaderError) Error() string
type UnknownTableSpaceError ¶
type UnknownTableSpaceError struct {
// contains filtered or unexported fields
}
func NewUnknownTableSpaceError ¶
func NewUnknownTableSpaceError() UnknownTableSpaceError
func (UnknownTableSpaceError) Error ¶
func (err UnknownTableSpaceError) Error() string
type UnsetEnvVarError ¶
type UnsetEnvVarError struct {
// contains filtered or unexported fields
}
UnsetEnvVarError is used to indicate required environment variables for WAL-G.
func NewUnsetEnvVarError ¶
func NewUnsetEnvVarError(names []string) UnsetEnvVarError
func (UnsetEnvVarError) Error ¶
func (err UnsetEnvVarError) Error() string
type UnsupportedFileTypeError ¶
type UnsupportedFileTypeError struct {
// contains filtered or unexported fields
}
UnsupportedFileTypeError is used to signal file types that are unsupported by WAL-G.
func NewUnsupportedFileTypeError ¶
func NewUnsupportedFileTypeError(path string, fileFormat string) UnsupportedFileTypeError
type UnsupportedPostgresVersionError ¶
type UnsupportedPostgresVersionError struct {
// contains filtered or unexported fields
}
func NewUnsupportedPostgresVersionError ¶
func NewUnsupportedPostgresVersionError(version int) UnsupportedPostgresVersionError
func (UnsupportedPostgresVersionError) Error ¶
func (err UnsupportedPostgresVersionError) Error() string
type UntilEOFReader ¶
type UntilEOFReader struct {
// contains filtered or unexported fields
}
func NewUntilEofReader ¶
func NewUntilEofReader(underlying io.Reader) *UntilEOFReader
type Uploader ¶
type Uploader struct { Success bool // contains filtered or unexported fields }
Uploader contains fields associated with uploading tarballs. Multiple tarballs can share one uploader.
func NewUploader ¶
func NewUploader( compressor Compressor, uploadingLocation StorageFolder, deltaDataFolder DataFolder, useWalDelta, preventWalOverwrite bool, ) *Uploader
func (*Uploader) UploadFile ¶
func (uploader *Uploader) UploadFile(file NamedReader) error
TODO : unit tests UploadFile compresses a file and uploads it.
func (*Uploader) UploadWalFile ¶
func (uploader *Uploader) UploadWalFile(file NamedReader) error
TODO : unit tests
type WalDeltaRecorder ¶
type WalDeltaRecorder struct {
// contains filtered or unexported fields
}
func NewWalDeltaRecorder ¶
func NewWalDeltaRecorder(blockLocationConsumer chan walparser.BlockLocation) *WalDeltaRecorder
type WalDeltaRecordingReader ¶
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 ¶
func NewWalDeltaRecordingReader(walFileReader io.Reader, walFilename string, manager *DeltaFileManager) (*WalDeltaRecordingReader, error)
func (*WalDeltaRecordingReader) Close ¶
func (reader *WalDeltaRecordingReader) Close() error
func (*WalDeltaRecordingReader) Read ¶
func (reader *WalDeltaRecordingReader) Read(p []byte) (n int, err error)
func (*WalDeltaRecordingReader) RecordBlockLocationsFromPage ¶
func (reader *WalDeltaRecordingReader) RecordBlockLocationsFromPage() error
type WalPart ¶
type WalPart struct {
// contains filtered or unexported fields
}
func NewWalPart ¶
func NewWalPart(dataType WalPartDataType, id uint8, data []byte) *WalPart
type WalPartDataType ¶
type WalPartDataType uint8
const ( PreviousWalHeadType WalPartDataType = 0 WalTailType WalPartDataType = 1 WalHeadType WalPartDataType = 2 )
type WalPartFile ¶
func LoadPartFile ¶
func LoadPartFile(reader io.Reader) (*WalPartFile, error)
func NewWalPartFile ¶
func NewWalPartFile() *WalPartFile
func (*WalPartFile) CombineRecords ¶
func (partFile *WalPartFile) CombineRecords() ([]walparser.XLogRecord, error)
func (*WalPartFile) IsComplete ¶
func (partFile *WalPartFile) IsComplete() bool
type WalPartRecorder ¶
type WalPartRecorder struct {
// contains filtered or unexported fields
}
func NewWalPartRecorder ¶
func NewWalPartRecorder(walFilename string, manager *DeltaFileManager) (*WalPartRecorder, error)
func (*WalPartRecorder) SaveNextWalHead ¶
func (recorder *WalPartRecorder) SaveNextWalHead(head []byte) error
func (*WalPartRecorder) SavePreviousWalTail ¶
func (recorder *WalPartRecorder) SavePreviousWalTail(tailData []byte) error
type WrongTypeError ¶
type WrongTypeError struct {
// contains filtered or unexported fields
}
func NewWrongTypeError ¶
func NewWrongTypeError(desiredType string) WrongTypeError
func (WrongTypeError) Error ¶
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 ¶
type ZstdCompressor struct{}
func (ZstdCompressor) FileExtension ¶
func (compressor ZstdCompressor) FileExtension() string
func (ZstdCompressor) NewWriter ¶
func (compressor ZstdCompressor) NewWriter(writer io.Writer) ReaderFromWriteCloser
type ZstdDecompressor ¶
type ZstdDecompressor struct{}
func (ZstdDecompressor) Decompress ¶
func (ZstdDecompressor) FileExtension ¶
func (decompressor ZstdDecompressor) FileExtension() string
type ZstdReaderFromWriter ¶
func NewZstdReaderFromWriter ¶
func NewZstdReaderFromWriter(dst io.Writer) *ZstdReaderFromWriter
Source Files ¶
- backup.go
- backup_fetch_handler.go
- backup_file_description.go
- backup_list_handler.go
- backup_push_handler.go
- backup_sentinel_dto.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
- compressing_pipe_writer.go
- compression.go
- config.go
- configure.go
- connect.go
- crypter.go
- crypto.go
- data_folder.go
- delay_write_closer.go
- delete_handler.go
- delta_file.go
- delta_file_chan_writer.go
- delta_file_manager.go
- disk_data_folder.go
- errors.go
- exponential_retrier.go
- extract.go
- file_storage_object.go
- file_system_cleaner.go
- fs_folder.go
- gcs_folder.go
- gs_storage_object.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_storage_object.go
- s3_uploader.go
- saver.go
- sentinel.go
- storage_folder.go
- storage_object.go
- storage_tar_ball.go
- storage_tar_ball_maker.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_fetch_handler.go
- wal_part.go
- wal_part_file.go
- wal_part_recorder.go
- wal_push_handler.go
- zstd_compressor.go
- zstd_decompressor.go
- zstd_reader_from_writer.go