binary

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: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ComputeMongoStartTimeout

func ComputeMongoStartTimeout(backupUncompressedSize int64) time.Duration

ComputeMongoStartTimeout compute timeout with formula max(10min, UncompressedSizeTb * 40min)

func EnsureCompatibilityToRestoreMongodVersions

func EnsureCompatibilityToRestoreMongodVersions(backupMongodVersion, restoreMongodVersion string) error

func GenerateNewBackupName

func GenerateNewBackupName() string

func MajorMinorVersion

func MajorMinorVersion(version string) string

MajorMinorVersion return version in format '<MajorVersion>.<MinorVersion>' (without patch, prerelease, build, ...)

func MajorVersion

func MajorVersion(version string) string

MajorVersion return version in format '<MajorVersion>' (without minor, patch, prerelease, build, ...)

func NextMajorVersion

func NextMajorVersion(version string) string

NextMajorVersion return next major version in format '<MajorVersion> + 1' (without minor, patch, prerelease, build, ...)

Types

type BackupCursor

type BackupCursor struct {
	*mongo.Cursor

	BackupCursorMeta *BackupCursorMeta
	// contains filtered or unexported fields
}

func CreateBackupCursor

func CreateBackupCursor(mongodService *MongodService) (*BackupCursor, error)

func (*BackupCursor) Close

func (backupCursor *BackupCursor) Close()

func (*BackupCursor) LoadBackupCursorFiles

func (backupCursor *BackupCursor) LoadBackupCursorFiles() (backupFiles []*BackupFileMeta, err error)

func (*BackupCursor) LoadExtendedBackupCursorFiles

func (backupCursor *BackupCursor) LoadExtendedBackupCursorFiles() (backupFiles []*BackupFileMeta, err error)

func (*BackupCursor) StartKeepAlive

func (backupCursor *BackupCursor) StartKeepAlive()

type BackupCursorFile

type BackupCursorFile struct {
	FileName string `bson:"filename" json:"filename"`
	FileSize int64  `bson:"fileSize" json:"fileSize"`
}

type BackupCursorMeta

type BackupCursorMeta struct {
	ID                       primitive.Binary    `bson:"backupId"`
	DBPath                   string              `bson:"dbpath"`
	OplogStart               BackupCursorOplogTS `bson:"oplogStart"`
	OplogEnd                 BackupCursorOplogTS `bson:"oplogEnd"`
	CheckpointTS             primitive.Timestamp `bson:"checkpointTimestamp"`
	DisableIncrementalBackup bool                `bson:"disableIncrementalBackup"`
	IncrementalBackup        bool                `bson:"incrementalBackup"`
	BlockSize                int64               `bson:"blockSize"`
}

type BackupCursorOplogTS

type BackupCursorOplogTS struct {
	TS primitive.Timestamp `bson:"ts"`
	T  int64               `bson:"t"`
}

type BackupFileMeta

type BackupFileMeta struct {
	Path     string
	FileMode os.FileMode
	FileSize int64
}

func (*BackupFileMeta) IsDir

func (backupFileMeta *BackupFileMeta) IsDir() bool

func (*BackupFileMeta) ModTime

func (backupFileMeta *BackupFileMeta) ModTime() time.Time

func (*BackupFileMeta) Mode

func (backupFileMeta *BackupFileMeta) Mode() os.FileMode

func (*BackupFileMeta) Name

func (backupFileMeta *BackupFileMeta) Name() string

func (*BackupFileMeta) Size

func (backupFileMeta *BackupFileMeta) Size() int64

func (*BackupFileMeta) Sys

func (backupFileMeta *BackupFileMeta) Sys() any

type BackupService

type BackupService struct {
	Context       context.Context
	MongodService *MongodService
	Uploader      internal.Uploader

	Sentinel models.Backup
}

func CreateBackupService

func CreateBackupService(ctx context.Context, mongodService *MongodService, uploader internal.Uploader,
) (*BackupService, error)

func (*BackupService) DoBackup

func (backupService *BackupService) DoBackup(backupName string, permanent bool) error

func (*BackupService) Finalize

func (backupService *BackupService) Finalize(uploader *ConcurrentUploader, backupCursorMeta *BackupCursorMeta) error

func (*BackupService) InitializeMongodBackupMeta

func (backupService *BackupService) InitializeMongodBackupMeta(backupName string, permanent bool) error

type ConcurrentDownloader

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

func CreateConcurrentDownloader

func CreateConcurrentDownloader(uploader internal.Uploader) *ConcurrentDownloader

func (*ConcurrentDownloader) Download

func (downloader *ConcurrentDownloader) Download(backupName, localDirectory string) error

type ConcurrentUploader

type ConcurrentUploader struct {
	UncompressedSize int64
	CompressedSize   int64
	// contains filtered or unexported fields
}

func CreateConcurrentUploader

func CreateConcurrentUploader(uploader internal.Uploader, backupName, directory string) (*ConcurrentUploader, error)

func (*ConcurrentUploader) Finalize

func (concurrentUploader *ConcurrentUploader) Finalize() error

func (*ConcurrentUploader) Upload

func (concurrentUploader *ConcurrentUploader) Upload(backupFile *BackupFileMeta) error

func (*ConcurrentUploader) UploadBackupFiles

func (concurrentUploader *ConcurrentUploader) UploadBackupFiles(backupFiles []*BackupFileMeta) error

type LocalStorage

type LocalStorage struct {
	MongodDBPath string
}

func CreateLocalStorage

func CreateLocalStorage(mongodDBPath string) *LocalStorage

func (*LocalStorage) CleanupMongodDBPath

func (localStorage *LocalStorage) CleanupMongodDBPath() error

func (*LocalStorage) EnsureEmptyDBPath

func (localStorage *LocalStorage) EnsureEmptyDBPath() error

func (*LocalStorage) EnsureMongodFsLockFileIsEmpty

func (localStorage *LocalStorage) EnsureMongodFsLockFileIsEmpty() error

type MongodConfig

type MongodConfig struct {
	Net struct {
		BindIP string `bson:"bindIp" json:"bindIp"`
		Port   int    `bson:"port" json:"port"`
	} `bson:"net" json:"net"`
	Storage struct {
		DBPath string `bson:"dbPath" json:"dbPath"`
	} `bson:"storage" json:"storage"`
}

type MongodFileConfig

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

func CreateMongodConfig

func CreateMongodConfig(path string) (*MongodFileConfig, error)

func (*MongodFileConfig) Get

func (mongodFileConfig *MongodFileConfig) Get(key string) any

func (*MongodFileConfig) GetDBPath

func (mongodFileConfig *MongodFileConfig) GetDBPath() string

func (*MongodFileConfig) SaveConfigToTempFile

func (mongodFileConfig *MongodFileConfig) SaveConfigToTempFile(keys ...string) (string, error)

type MongodProcess

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

func StartMongo

func StartMongo(minimalConfigPath string, parameters ...string) (*MongodProcess, error)

func StartMongodWithDisableLogicalSessionCacheRefresh

func StartMongodWithDisableLogicalSessionCacheRefresh(minimalConfigPath string) (*MongodProcess, error)

func StartMongodWithRecoverFromOplogAsStandalone

func StartMongodWithRecoverFromOplogAsStandalone(minimalConfigPath string) (*MongodProcess, error)

func (*MongodProcess) Close

func (mongodProcess *MongodProcess) Close()

func (*MongodProcess) GetHostWithPort

func (mongodProcess *MongodProcess) GetHostWithPort() string

func (*MongodProcess) GetURI

func (mongodProcess *MongodProcess) GetURI() string

func (*MongodProcess) Wait

func (mongodProcess *MongodProcess) Wait() error

type MongodService

type MongodService struct {
	Context     context.Context
	MongoClient *mongo.Client
}

func CreateMongodService

func CreateMongodService(ctx context.Context, appName, mongodbURI string, timeout time.Duration) (*MongodService, error)

func (*MongodService) FixSystemDataAfterRestore

func (mongodService *MongodService) FixSystemDataAfterRestore(rsConfig RsConfig) error

func (*MongodService) GetBackupCursor

func (mongodService *MongodService) GetBackupCursor() (cursor *mongo.Cursor, err error)

func (*MongodService) GetBackupCursorExtended

func (mongodService *MongodService) GetBackupCursorExtended(backupCursorMeta *BackupCursorMeta) (*mongo.Cursor, error)

func (*MongodService) GetReplSetName

func (mongodService *MongodService) GetReplSetName() (string, error)

func (*MongodService) MongodConfig

func (mongodService *MongodService) MongodConfig() (*MongodConfig, error)

func (*MongodService) MongodVersion

func (mongodService *MongodService) MongodVersion() (string, error)

func (*MongodService) Shutdown

func (mongodService *MongodService) Shutdown() error

type RestoreService

type RestoreService struct {
	Context      context.Context
	LocalStorage *LocalStorage
	Uploader     internal.Uploader
	// contains filtered or unexported fields
}

func CreateRestoreService

func CreateRestoreService(ctx context.Context, localStorage *LocalStorage, uploader internal.Uploader,
	minimalConfigPath string) (*RestoreService, error)

func (*RestoreService) DoRestore

func (restoreService *RestoreService) DoRestore(backupName, restoreMongodVersion string, rsConfig RsConfig) error

type RsConfig

type RsConfig struct {
	RsName    string
	RsMembers string
}

func (RsConfig) Empty

func (rsConfig RsConfig) Empty() bool

func (RsConfig) Validate

func (rsConfig RsConfig) Validate() error

Jump to

Keyboard shortcuts

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