Documentation ¶
Index ¶
- Constants
- Variables
- func AddRSMeta(ctx context.Context, conn connect.Client, bcpName string, rs BackupReplset) error
- func BackupHB(ctx context.Context, conn connect.Client, bcpName string) error
- func CanDeleteBackup(ctx context.Context, conn connect.Client, bcp *BackupMeta) error
- func CanDeleteIncrementalChain(ctx context.Context, conn connect.Client, base *BackupMeta, ...) error
- func ChangeBackupState(conn connect.Client, bcpName string, s defs.Status, msg string) error
- func ChangeBackupStateOPID(conn connect.Client, opid string, s defs.Status, msg string) error
- func ChangeBackupStateWithUnixTime(ctx context.Context, conn connect.Client, bcpName string, s defs.Status, ...) error
- func ChangeRSState(conn connect.Client, bcpName, rsName string, s defs.Status, msg string) error
- func CheckBackupDataFiles(ctx context.Context, stg storage.Storage, bcp *BackupMeta) error
- func CheckBackupFiles(ctx context.Context, stg storage.Storage, name string) error
- func DeleteBackup(ctx context.Context, conn connect.Client, name, node string) error
- func DeleteBackupBefore(ctx context.Context, conn connect.Client, t time.Time, bcpType defs.BackupType, ...) error
- func DeleteBackupFiles(stg storage.Storage, backupName string) error
- func FetchAllIncrements(ctx context.Context, conn connect.Client, base *BackupMeta) ([][]*BackupMeta, error)
- func FindBaseSnapshotLWAfter(ctx context.Context, conn connect.Client, lw primitive.Timestamp) (primitive.Timestamp, error)
- func FindBaseSnapshotLWBefore(ctx context.Context, conn connect.Client, lw primitive.Timestamp, ...) (primitive.Timestamp, error)
- func FormatChunkName(start, end primitive.Timestamp, cmp compress.CompressionType) string
- func IncBackupSize(ctx context.Context, conn connect.Client, bcpName string, size int64) error
- func NewDBManager(conn connect.Client) *dbMangerImpl
- func ParseChunkName(filename string) (start primitive.Timestamp, end primitive.Timestamp, ...)
- func ParseDeleteBackupType(s string) (defs.BackupType, error)
- func ReadArchiveNamespaces(stg storage.Storage, metafile string) ([]*archive.Namespace, error)
- func SetFirstWrite(ctx context.Context, conn connect.Client, bcpName string, ...) error
- func SetLastWrite(ctx context.Context, conn connect.Client, bcpName string, ...) error
- func SetRSLastWrite(conn connect.Client, bcpName, rsName string, ts primitive.Timestamp) error
- func SetRSNomination(ctx context.Context, conn connect.Client, bcpName, rs string) error
- func SetRSNomineeACK(ctx context.Context, conn connect.Client, bcpName, rsName, node string) error
- func SetRSNominees(ctx context.Context, conn connect.Client, bcpName, rsName string, ...) error
- func SetSrcBackup(ctx context.Context, conn connect.Client, bcpName, srcName string) error
- type BCoplogTS
- type Backup
- func New(leadConn connect.Client, conn *mongo.Client, brief topo.NodeBrief, ...) *Backup
- func NewExternal(leadConn connect.Client, conn *mongo.Client, brief topo.NodeBrief) *Backup
- func NewIncremental(leadConn connect.Client, conn *mongo.Client, brief topo.NodeBrief, base bool) *Backup
- func NewPhysical(leadConn connect.Client, conn *mongo.Client, brief topo.NodeBrief) *Backup
- func (b *Backup) Init(ctx context.Context, bcp *ctrl.BackupCmd, opid ctrl.OPID, ...) error
- func (b *Backup) Run(ctx context.Context, bcp *ctrl.BackupCmd, opid ctrl.OPID, l log.LogEvent) (err error)
- func (b *Backup) SetConfig(cfg *config.Config)
- func (b *Backup) SetMongoVersion(v string)
- func (b *Backup) SetSlicerInterval(d time.Duration)
- func (b *Backup) SetTimeouts(t *config.BackupTimeouts)
- func (b *Backup) SlicerInterval() time.Duration
- type BackupCursor
- type BackupCursorData
- type BackupMeta
- func BackupsDoneList(ctx context.Context, conn connect.Client, after *primitive.Timestamp, ...) ([]BackupMeta, error)
- func BackupsList(ctx context.Context, conn connect.Client, limit int64) ([]BackupMeta, error)
- func GetBackupByOPID(ctx context.Context, conn connect.Client, opid string) (*BackupMeta, error)
- func GetFirstBackup(ctx context.Context, conn connect.Client, after *primitive.Timestamp) (*BackupMeta, error)
- func GetLastBackup(ctx context.Context, conn connect.Client, before *primitive.Timestamp) (*BackupMeta, error)
- func LastIncrementalBackup(ctx context.Context, conn connect.Client) (*BackupMeta, error)
- func ListDeleteBackupBefore(ctx context.Context, conn connect.Client, ts primitive.Timestamp, ...) ([]BackupMeta, error)
- func ReadMetadata(stg storage.Storage, filename string) (*BackupMeta, error)
- type BackupReplset
- type BackupRsNomination
- type CleanupInfo
- type Condition
- type File
- type Filelist
- type Manager
- type Meta
- type Storage
- type UUID
Constants ¶
const FilelistName = "filelist.pbm"
FilelistName is filename that is used to store list of files for physical backup
const SelectiveBackup defs.BackupType = "selective"
Variables ¶
var ( ErrBackupInProgress = errors.New("backup is in progress") ErrIncrementalBackup = errors.New("backup is incremental") ErrNonIncrementalBackup = errors.New("backup is not incremental") ErrNotBaseIncrement = errors.New("backup is not base increment") ErrBaseForPITR = errors.New("cannot delete the last PITR base snapshot while PITR is enabled") )
var ErrInvalidDeleteBackupType = errors.New("invalid backup type")
Functions ¶
func CanDeleteBackup ¶
func CanDeleteIncrementalChain ¶
func CanDeleteIncrementalChain( ctx context.Context, conn connect.Client, base *BackupMeta, increments [][]*BackupMeta, ) error
func ChangeBackupState ¶
func ChangeBackupStateOPID ¶
func ChangeRSState ¶
func CheckBackupDataFiles ¶
func CheckBackupFiles ¶
func DeleteBackup ¶
DeleteBackup deletes backup with the given name from the current storage and pbm database
func DeleteBackupBefore ¶
func DeleteBackupBefore( ctx context.Context, conn connect.Client, t time.Time, bcpType defs.BackupType, node string, ) error
DeleteBackupBefore deletes backups which are older than given time
func DeleteBackupFiles ¶
DeleteBackupFiles removes backup's artifacts from storage
func FetchAllIncrements ¶
func FetchAllIncrements( ctx context.Context, conn connect.Client, base *BackupMeta, ) ([][]*BackupMeta, error)
func FindBaseSnapshotLWAfter ¶
func FormatChunkName ¶
func FormatChunkName(start, end primitive.Timestamp, cmp compress.CompressionType) string
func IncBackupSize ¶
func NewDBManager ¶
func ParseChunkName ¶
func ParseDeleteBackupType ¶
func ParseDeleteBackupType(s string) (defs.BackupType, error)
func ReadArchiveNamespaces ¶
func SetFirstWrite ¶
func SetLastWrite ¶
func SetRSLastWrite ¶
func SetRSNomination ¶
func SetRSNomineeACK ¶
func SetRSNominees ¶
Types ¶
type Backup ¶
type Backup struct {
// contains filtered or unexported fields
}
func NewExternal ¶
func NewIncremental ¶
func NewPhysical ¶ added in v1.7.0
func (*Backup) Run ¶
func (b *Backup) Run(ctx context.Context, bcp *ctrl.BackupCmd, opid ctrl.OPID, l log.LogEvent) (err error)
Run runs backup. TODO: describe flow
func (*Backup) SetMongoVersion ¶
func (*Backup) SetSlicerInterval ¶
func (*Backup) SetTimeouts ¶
func (b *Backup) SetTimeouts(t *config.BackupTimeouts)
func (*Backup) SlicerInterval ¶
type BackupCursor ¶ added in v1.7.0
type BackupCursor struct { CustomThisID string // contains filtered or unexported fields }
func NewBackupCursor ¶ added in v1.7.0
func (*BackupCursor) Close ¶ added in v1.7.0
func (bc *BackupCursor) Close()
func (*BackupCursor) Data ¶ added in v1.7.0
func (bc *BackupCursor) Data(ctx context.Context) (_ *BackupCursorData, err error)
type BackupCursorData ¶ added in v1.7.0
type BackupMeta ¶
type BackupMeta struct { Type defs.BackupType `bson:"type" json:"type"` OPID string `bson:"opid" json:"opid"` Name string `bson:"name" json:"name"` // SrcBackup is the source for the incremental backups. The souce might be // incremental as well. // Empty means this is a full backup (and a base for further incremental bcps). SrcBackup string `bson:"src_backup,omitempty" json:"src_backup,omitempty"` // Increments is a list of all increments, including failed or canceled. // Each top-level slice cell contains the list of the next incremental backup attempts. // If the value is nil, increments have not been fetched. // If the value is an empty non-nil slice, no increment exists. Increments [][]*BackupMeta `bson:"-" json:"-"` // ShardRemap is map of replset to shard names. // If shard name is different from replset name, it will be stored in the map. // If all shard names are the same as their replset names, the map is nil. ShardRemap map[string]string `bson:"shardRemap,omitempty" json:"shardRemap,omitempty"` Namespaces []string `bson:"nss,omitempty" json:"nss,omitempty"` Replsets []BackupReplset `bson:"replsets" json:"replsets"` Compression compress.CompressionType `bson:"compression" json:"compression"` Store Storage `bson:"store" json:"store"` Size int64 `bson:"size" json:"size"` MongoVersion string `bson:"mongodb_version" json:"mongodb_version"` FCV string `bson:"fcv" json:"fcv"` StartTS int64 `bson:"start_ts" json:"start_ts"` LastTransitionTS int64 `bson:"last_transition_ts" json:"last_transition_ts"` FirstWriteTS primitive.Timestamp `bson:"first_write_ts" json:"first_write_ts"` LastWriteTS primitive.Timestamp `bson:"last_write_ts" json:"last_write_ts"` Hb primitive.Timestamp `bson:"hb" json:"hb"` Status defs.Status `bson:"status" json:"status"` Conditions []Condition `bson:"conditions" json:"conditions"` Nomination []BackupRsNomination `bson:"n" json:"n"` Err string `bson:"error,omitempty" json:"error,omitempty"` PBMVersion string `bson:"pbm_version" json:"pbm_version"` BalancerStatus topo.BalancerMode `bson:"balancer" json:"balancer"` // contains filtered or unexported fields }
BackupMeta is a backup's metadata
func BackupsDoneList ¶
func BackupsList ¶
func GetBackupByOPID ¶
func GetFirstBackup ¶
func GetLastBackup ¶
func GetLastBackup(ctx context.Context, conn connect.Client, before *primitive.Timestamp) (*BackupMeta, error)
GetLastBackup returns last successfully finished backup (non-selective and non-external) or nil if there is no such backup yet. If ts isn't nil it will search for the most recent backup that finished before specified timestamp
func LastIncrementalBackup ¶
func ListDeleteBackupBefore ¶
func ListDeleteBackupBefore( ctx context.Context, conn connect.Client, ts primitive.Timestamp, bcpType defs.BackupType, ) ([]BackupMeta, error)
func ReadMetadata ¶
func ReadMetadata(stg storage.Storage, filename string) (*BackupMeta, error)
func (*BackupMeta) Error ¶
func (b *BackupMeta) Error() error
func (*BackupMeta) RS ¶
func (b *BackupMeta) RS(name string) *BackupReplset
RS returns the metadata of the replset with given name. It returns nil if no replset found.
func (*BackupMeta) SetRuntimeError ¶
func (b *BackupMeta) SetRuntimeError(err error)
type BackupReplset ¶
type BackupReplset struct { Name string `bson:"name" json:"name"` // Journal is not used. left for backward compatibility Journal []File `bson:"journal,omitempty" json:"journal,omitempty"` Files []File `bson:"files,omitempty" json:"files,omitempty"` DumpName string `bson:"dump_name,omitempty" json:"backup_name,omitempty"` OplogName string `bson:"oplog_name,omitempty" json:"oplog_name,omitempty"` StartTS int64 `bson:"start_ts" json:"start_ts"` Status defs.Status `bson:"status" json:"status"` IsConfigSvr *bool `bson:"iscs,omitempty" json:"iscs,omitempty"` IsConfigShard *bool `bson:"configshard,omitempty" json:"configshard,omitempty"` LastTransitionTS int64 `bson:"last_transition_ts" json:"last_transition_ts"` FirstWriteTS primitive.Timestamp `bson:"first_write_ts" json:"first_write_ts"` LastWriteTS primitive.Timestamp `bson:"last_write_ts" json:"last_write_ts"` Node string `bson:"node" json:"node"` // node that performed backup Error string `bson:"error,omitempty" json:"error,omitempty"` Conditions []Condition `bson:"conditions" json:"conditions"` MongodOpts *topo.MongodOpts `bson:"mongod_opts,omitempty" json:"mongod_opts,omitempty"` // required for external backup (PBM-1252) PBMVersion string `bson:"pbm_version,omitempty" json:"pbm_version,omitempty"` MongoVersion string `bson:"mongo_version,omitempty" json:"mongo_version,omitempty"` // CustomThisID is customized thisBackupName value for $backupCursor (in WT: "this_id"). // If it is not set (empty), the default value was used. CustomThisID string `bson:"this_id,omitempty" json:"this_id,omitempty"` }
type BackupRsNomination ¶
type BackupRsNomination struct { RS string `bson:"rs" json:"rs"` Nodes []string `bson:"n" json:"n"` Ack string `bson:"ack" json:"ack"` }
BackupRsNomination is used to choose (nominate and elect) nodes for the backup within a replica set
func GetRSNominees ¶
type CleanupInfo ¶
type CleanupInfo struct { Backups []BackupMeta `json:"backups"` Chunks []oplog.OplogChunk `json:"chunks"` }
func MakeCleanupInfo ¶
type File ¶
type File struct { Name string `bson:"filename" json:"filename"` Off int64 `bson:"offset" json:"offset"` // offset for incremental backups Len int64 `bson:"length" json:"length"` // length of chunk after the offset Size int64 `bson:"fileSize" json:"fileSize"` StgSize int64 `bson:"stgSize" json:"stgSize"` Fmode os.FileMode `bson:"fmode" json:"fmode"` }
type Filelist ¶
type Filelist []File
Filelist represents a list of files.
func ReadFilelistForReplset ¶
type Manager ¶
type Manager interface { GetAllBackups(ctx context.Context) ([]BackupMeta, error) GetBackupByName(ctx context.Context, name string) (*BackupMeta, error) GetBackupByOpID(ctx context.Context, opid string) (*BackupMeta, error) }
type Storage ¶
type Storage struct { // Name is config profile name. Name string `bson:"name,omitempty" json:"name,omitempty"` // IsProfile is true when storage is non-main (external). IsProfile bool `bson:"profile,omitempty" json:"profile,omitempty"` config.StorageConf `bson:",inline" json:",inline"` }
Storage keeps storage configuration used during backup.
If external configuration is used, IsProfile is `true` and Name is set.