backup

package
v0.0.0-debug-20260702 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2026 License: Apache-2.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// FileIndexPrefix is the prefix for file index files
	FileIndexPrefix = "file_index_"
	// FileIndexSuffix is the suffix for file index files
	FileIndexSuffix = ".idx"
)
View Source
const (
	TypePos              = 0
	SubTypePos           = 1
	FileNameOrDirNamePos = 2
)

Format :type,subtype,filename or dirname

View Source
const (
	CnConfig     = "cn"
	DnConfig     = "dn"
	LogConfig    = "log"
	ProxyConfig  = "proxy"
	LaunchConfig = "launch"
)
View Source
const (
	HakeeperFile = "hk_data"
)
View Source
const (
	Version = "0823"
)

Variables

This section is empty.

Functions

func Backup

func Backup(
	ctx context.Context,
	sid string,
	bs *tree.BackupStart,
	cfg *Config,
) error

Backup Note: ctx needs to support cancel. The user can cancel the backup task by canceling the ctx.

func BackupData

func BackupData(
	ctx context.Context,
	sid string,
	srcFs, dstFs fileservice.FileService,
	dir string,
	config *Config,
	globalIndex *GlobalFileIndex,
) error

func CopyCheckpointDir added in v1.2.2

func CopyCheckpointDir(
	ctx context.Context,
	srcFs, dstFs fileservice.FileService,
	dir string, backup types.TS,
) ([]*taeFile, types.TS, error)

func CopyFile

func CopyFile(ctx context.Context, srcFs, dstFs fileservice.FileService, name, dstDir string, newNames ...string) ([]byte, error)

CopyFile copy file from srcFs to dstFs and return checksum of the written file.

func CopyFileWithRetry added in v1.2.0

func CopyFileWithRetry(ctx context.Context, srcFs, dstFs fileservice.FileService, name, dstDir string, newName ...string) ([]byte, error)

func CopyGCDir added in v1.2.2

func CopyGCDir(
	ctx context.Context,
	srcFs, dstFs fileservice.FileService,
	dir string,
	backup, min types.TS,
) ([]*taeFile, error)

func SaveLaunchConfigPath

func SaveLaunchConfigPath(typ string, paths []string)

SaveLaunchConfigPath saves all config file paths for the standalone config

func ToCsvLine2

func ToCsvLine2(s [][]string) (string, error)

Types

type Config

type Config struct {
	// Timestamp
	Timestamp types.TS

	// For General usage
	GeneralDir fileservice.FileService

	// For locating tae's storage fs
	SharedFs fileservice.FileService

	// For tae and hakeeper
	TaeDir fileservice.FileService

	// hakeeper client
	HAkeeper logservice.BRHAKeeperClient

	Metas *Metas

	// For parallel backup
	Parallelism uint16

	BackupType string
	BackupTs   types.TS
}

type GlobalFileIndex

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

GlobalFileIndex represents the global file index for backup It maps filename to whether the file has been backed up

func LoadGlobalFileIndex

func LoadGlobalFileIndex(ctx context.Context, rootFs fileservice.FileService) (*GlobalFileIndex, error)

LoadGlobalFileIndex loads the latest global file index from the backup root directory rootFs should be the file service pointing to the backup root directory (parent of current backup)

func NewGlobalFileIndex

func NewGlobalFileIndex() *GlobalFileIndex

NewGlobalFileIndex creates a new empty global file index

func (*GlobalFileIndex) Add

func (idx *GlobalFileIndex) Add(fileName string)

Add adds a file to the index

func (*GlobalFileIndex) Has

func (idx *GlobalFileIndex) Has(fileName string) bool

Has checks if a file exists in the index

func (*GlobalFileIndex) Size

func (idx *GlobalFileIndex) Size() int

Size returns the number of files in the index

type Meta

type Meta struct {
	Typ               MetaType
	SubTyp            string
	FileNameOrDirName string

	//version
	Version string

	//build info
	Buildinfo string

	//launch config
	LaunchConfigFile string
}

Meta of mo_meta same as the mo_br

func (*Meta) CsvString

func (m *Meta) CsvString() []string

func (*Meta) String

func (m *Meta) String() string

type MetaType

type MetaType int
const (
	/**
	  backup_meta | mo_meta
	    ID        |
	    Version   | Version
	    Buildinfo | Buildinfo
	              | Launchconfig
	              | Tae
	              | Hakeeper
	*/
	TypeVersion MetaType = iota
	TypeBuildinfo
	TypeLaunchconfig
)

func (MetaType) String

func (t MetaType) String() string

type Metas

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

func NewMetas

func NewMetas() *Metas

func (*Metas) Append

func (m *Metas) Append(meta *Meta)

func (*Metas) AppendBuildinfo

func (m *Metas) AppendBuildinfo(info string)

func (*Metas) AppendLaunchconfig

func (m *Metas) AppendLaunchconfig(subTyp, file string)

func (*Metas) AppendVersion

func (m *Metas) AppendVersion(version string)

func (*Metas) CsvString

func (m *Metas) CsvString() [][]string

func (*Metas) String

func (m *Metas) String() string

Jump to

Keyboard shortcuts

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