archive

package
v0.0.0-...-e89a0ad Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BackupNamesFromBackupTimes

func BackupNamesFromBackupTimes(backups []internal.BackupTime) []string

BackupNamesFromBackupTimes forms list of backup names from BackupTime

func BackupNamesFromBackups

func BackupNamesFromBackups(backups []*models.Backup) []string

BackupNamesFromBackups forms list of backup names from Backups

func LastKnownInBackupTS

func LastKnownInBackupTS(backups []*models.Backup) (models.Timestamp, error)

LastKnownInBackupTS returns begin_ts of oldest backup

func MongoModelToTimedBackup

func MongoModelToTimedBackup(backups []*models.Backup) []internal.TimedBackup

func NewBackupMongoMetaConstructor

func NewBackupMongoMetaConstructor(ctx context.Context,
	mc client.MongoDriver,
	folder storage.Folder,
	permanent bool) internal.MetaConstructor

func OldestBackupAfterTime

func OldestBackupAfterTime(backups []*models.Backup, after time.Time) (*models.Backup, error)

OldestBackupAfterTime returns last backup after given time.

func SelectPurgingOplogArchives

func SelectPurgingOplogArchives(archives []models.Archive,
	backups []*models.Backup,
	retainAfterTS *models.Timestamp) []models.Archive

SelectPurgingOplogArchives builds archive list to be deleted.

func SplitMongoBackups

func SplitMongoBackups(backups []*models.Backup, purgeBackups, retainBackups map[string]bool) (purge, retain []*models.Backup)

func SplitPurgingOplogArchivesByTS

func SplitPurgingOplogArchivesByTS(archives []models.Archive, purgeBeforeTS models.Timestamp) []models.Archive

SplitPurgingOplogArchivesByTS returns archives with start_maj_ts < purgeBeforeTS.

Types

type DiscardUploader

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

DiscardUploader reads provided data and returns success

func NewDiscardUploader

func NewDiscardUploader(compressor compression.Compressor, readerFrom io.ReaderFrom) *DiscardUploader

NewDiscardUploader builds DiscardUploader.

func (*DiscardUploader) UploadBackup

func (d *DiscardUploader) UploadBackup(stream io.Reader, cmd internal.ErrWaiter, metaConstructor internal.MetaConstructor) error

UploadBackup is not implemented yet

func (*DiscardUploader) UploadGapArchive

func (d *DiscardUploader) UploadGapArchive(err error, firstTS, lastTS models.Timestamp) error

UploadGapArchive returns nil error

func (*DiscardUploader) UploadOplogArchive

func (d *DiscardUploader) UploadOplogArchive(archReader io.Reader, firstTS, lastTS models.Timestamp) error

UploadOplogArchive reads all data into memory, stream is compressed and encrypted if required

type Downloader

type Downloader interface {
	BackupMeta(name string) (*models.Backup, error)
	DownloadOplogArchive(arch models.Archive, writeCloser io.WriteCloser) error
	ListOplogArchives() ([]models.Archive, error)
	LoadBackups(names []string) ([]*models.Backup, error)
	ListBackups() ([]internal.BackupTime, []string, error)
	LastKnownArchiveTS() (models.Timestamp, error)
}

Downloader defines interface to fetch mongodb oplog archives

type MongoMetaConstructor

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

func (*MongoMetaConstructor) Finalize

func (m *MongoMetaConstructor) Finalize(backupName string) error

func (*MongoMetaConstructor) Init

func (m *MongoMetaConstructor) Init() error

func (*MongoMetaConstructor) Meta

func (*MongoMetaConstructor) MetaInfo

func (m *MongoMetaConstructor) MetaInfo() interface{}

type Purger

type Purger interface {
	DeleteBackups(backups []*models.Backup) error
	DeleteGarbage(garbage []string) error
	DeleteOplogArchives(archives []models.Archive) error
}

type Sequence

type Sequence []models.Archive

Sequence represents serial archive route

func SequenceBetweenTS

func SequenceBetweenTS(archives []models.Archive, since, until models.Timestamp) (Sequence, error)

SequenceBetweenTS builds archive order between since and until timestamps archives can be written since multiple nodes and overlap each over, some timestamps may be lost, we should detect these cases

func (Sequence) Reverse

func (p Sequence) Reverse()

Reverse sorts Sequence

type StorageDownloader

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

StorageDownloader extends base folder with mongodb specific.

func NewStorageDownloader

func NewStorageDownloader(opts StorageSettings) (*StorageDownloader, error)

NewStorageDownloader builds mongodb downloader.

func (*StorageDownloader) BackupMeta

func (sd *StorageDownloader) BackupMeta(name string) (*models.Backup, error)

BackupMeta downloads sentinel contents.

func (*StorageDownloader) DownloadOplogArchive

func (sd *StorageDownloader) DownloadOplogArchive(arch models.Archive, writeCloser io.WriteCloser) error

DownloadOplogArchive downloads, decompresses and decrypts (if needed) oplog archive.

func (*StorageDownloader) LastBackupName

func (sd *StorageDownloader) LastBackupName() (string, error)

LastBackupName get last backup

func (*StorageDownloader) LastKnownArchiveTS

func (sd *StorageDownloader) LastKnownArchiveTS() (models.Timestamp, error)

LastKnownArchiveTS returns the most recent existed timestamp in storage folder.

func (*StorageDownloader) ListBackups

func (sd *StorageDownloader) ListBackups() ([]internal.BackupTime, []string, error)

ListBackups lists backups in folder

func (*StorageDownloader) ListOplogArchives

func (sd *StorageDownloader) ListOplogArchives() ([]models.Archive, error)

ListOplogArchives fetches all oplog archives existed in storage.

func (*StorageDownloader) LoadBackups

func (sd *StorageDownloader) LoadBackups(names []string) ([]*models.Backup, error)

LoadBackups downloads backups metadata

type StoragePurger

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

StoragePurger deletes files in storage.

func NewStoragePurger

func NewStoragePurger(opts StorageSettings) (*StoragePurger, error)

NewStoragePurger builds mongodb StoragePurger.

func (*StoragePurger) DeleteBackups

func (sp *StoragePurger) DeleteBackups(backups []*models.Backup) error

DeleteBackups purges given backups files TODO: extract BackupLayout abstraction and provide DataPath(), SentinelPath(), Exists() methods

func (*StoragePurger) DeleteGarbage

func (sp *StoragePurger) DeleteGarbage(garbage []string) error

DeleteGarbage purges given garbage keys

func (*StoragePurger) DeleteOplogArchives

func (sp *StoragePurger) DeleteOplogArchives(archives []models.Archive) error

DeleteOplogArchives purges given oplogs files

type StorageSettings

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

StorageSettings defines storage relative paths

func NewDefaultStorageSettings

func NewDefaultStorageSettings() StorageSettings

NewDefaultStorageSettings builds default storage settings struct

type StorageUploader

type StorageUploader struct {
	internal.Uploader
	// contains filtered or unexported fields
}

StorageUploader extends base uploader with mongodb specific. is NOT thread-safe

func NewStorageUploader

func NewStorageUploader(upl internal.Uploader) *StorageUploader

NewStorageUploader builds mongodb uploader.

func (*StorageUploader) UploadBackup

func (su *StorageUploader) UploadBackup(stream io.Reader, cmd internal.ErrWaiter, metaConstructor internal.MetaConstructor) error

UploadBackup compresses a stream and uploads it.

func (*StorageUploader) UploadGapArchive

func (su *StorageUploader) UploadGapArchive(archErr error, firstTS, lastTS models.Timestamp) error

UploadGap uploads mark indicating archiving gap.

func (*StorageUploader) UploadOplogArchive

func (su *StorageUploader) UploadOplogArchive(stream io.Reader, firstTS, lastTS models.Timestamp) error

UploadOplogArchive compresses a stream and uploads it with given archive name.

type Uploader

type Uploader interface {
	UploadOplogArchive(stream io.Reader, firstTS, lastTS models.Timestamp) error // TODO: rename firstTS
	UploadGapArchive(err error, firstTS, lastTS models.Timestamp) error
	UploadBackup(stream io.Reader, cmd internal.ErrWaiter, metaConstructor internal.MetaConstructor) error
}

Uploader defines interface to store mongodb backups and oplog archives

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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