archive

package
v1.8.1-0...-0157f87 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2024 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const MaxBSONSize = db.MaxBSONSize
View Source
const MetaFile = "metadata.json"
View Source
const MetaFileV2 = "meta.pbm"

Variables

View Source
var RouterConfigCollections = []string{
	"chunks",
	"collections",
	"databases",
	"settings",
	"shards",
	"tags",
	"version",
}

Functions

func Compose

func Compose(w io.Writer, newReader NewReader, nsFilter NSFilterFn, concurrency int) error

func DefaultDocFilter

func DefaultDocFilter(string, bson.Raw) bool

func DefaultNSFilter

func DefaultNSFilter(string) bool

func GenerateV1FromV2

func GenerateV1FromV2(ctx context.Context, stg storage.Storage, bcp, rs string) error

func NSify

func NSify(db, coll string) string

func NewBackup

func NewBackup(ctx context.Context, options BackupOptions) (*backupImpl, error)

func ReadBSONBuffer

func ReadBSONBuffer(r io.Reader, buf []byte) ([]byte, error)

ReadBSONBuffer reads raw bson document from r reader using buf buffer

func ReadMetadata

func ReadMetadata(r io.Reader) (*archiveMeta, error)

func SecureWrite

func SecureWrite(w io.Writer, data []byte) error

Types

type ArchiveMetaV2

type ArchiveMetaV2 struct {
	Version       string `bson:"version"`
	ServerVersion string `bson:"serverVersion"`
	FCV           string `bson:"fcv"`

	Namespaces []*NamespaceV2 `bson:"specifications"`
}

type BackupOptions

type BackupOptions struct {
	Client  *mongo.Client
	NewFile NewWriter

	NSFilter  NSFilterFn
	DocFilter DocFilterFn

	ParallelColls int
}

type DocFilterFn

type DocFilterFn func(ns string, d bson.Raw) bool

DocFilter checks whether a document is selected for backup. Useful when only some documents are selected for backup.

type IndexSpec

type IndexSpec struct {
	Version int32 `bson:"v"`

	Key  bson.D `bson:"key"`
	Name string `bson:"name"`

	Sparse    *bool `bson:"sparse,omitempty"`
	Unique    *bool `bson:"unique,omitempty"`
	Clustered *bool `bson:"clustered,omitempty"`

	ExpireAfterSeconds *int32 `bson:"expireAfterSeconds,omitempty"`
}

type NSFilterFn

type NSFilterFn func(ns string) bool

NSFilterFn checks whether a namespace is selected for backup. Useful when only some namespaces are selected for backup.

type Namespace

type Namespace struct {
	*archive.CollectionMetadata `bson:",inline"`

	CRC  int64 `bson:"crc"`
	Size int64 `bson:"size"`
}

type NamespaceV2

type NamespaceV2 struct {
	DB      string `bson:"db"`
	Name    string `bson:"name"`
	Type    string `bson:"type"`
	UUID    string `bson:"uuid,omitempty"`
	Options bson.D `bson:"options,omitempty"`

	Indexes []*IndexSpec `bson:"indexes"`

	CRC  int64 `bson:"crc"`
	Size int64 `bson:"size"`
}

func (*NamespaceV2) IsBucketCollection

func (s *NamespaceV2) IsBucketCollection() bool

func (*NamespaceV2) IsCollection

func (s *NamespaceV2) IsCollection() bool

func (*NamespaceV2) IsSystemCollection

func (s *NamespaceV2) IsSystemCollection() bool

func (*NamespaceV2) IsTimeseries

func (s *NamespaceV2) IsTimeseries() bool

func (*NamespaceV2) IsView

func (s *NamespaceV2) IsView() bool

func (*NamespaceV2) NS

func (s *NamespaceV2) NS() string

type NewReader

type NewReader func(ns string) (io.ReadCloser, error)

type NewWriter

type NewWriter func(ns string) (io.WriteCloser, error)

Jump to

Keyboard shortcuts

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