backupstore

package module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2023 License: Apache-2.0 Imports: 22 Imported by: 0

README

Backupstore Build Status

Build

Run make.

This repo is using https://github.com/longhorn/docker-nfs-ganesha to create the NFS server.

Documentation

Index

Constants

View Source
const (
	VOLUME_SEPARATE_LAYER1 = 2
	VOLUME_SEPARATE_LAYER2 = 4

	VOLUME_DIRECTORY     = "volumes"
	VOLUME_CONFIG_FILE   = "volume.cfg"
	BACKUP_DIRECTORY     = "backups"
	BACKUP_CONFIG_PREFIX = "backup_"

	CFG_SUFFIX = ".cfg"
)
View Source
const (
	DEFAULT_BLOCK_SIZE        = 2 * 1024 * 1024
	LEGACY_COMPRESSION_METHOD = "gzip"

	BLOCKS_DIRECTORY      = "blocks"
	BLOCK_SEPARATE_LAYER1 = 2
	BLOCK_SEPARATE_LAYER2 = 4
	BLK_SUFFIX            = ".blk"

	PROGRESS_PERCENTAGE_BACKUP_SNAPSHOT = 95
	PROGRESS_PERCENTAGE_BACKUP_TOTAL    = 100
)
View Source
const (
	LOCKS_DIRECTORY       = "locks"
	LOCK_PREFIX           = "lock"
	LOCK_SUFFIX           = ".lck"
	LOCK_DURATION         = time.Second * 150
	LOCK_REFRESH_INTERVAL = time.Second * 60
	LOCK_CHECK_WAIT_TIME  = time.Second * 2
)
View Source
const (
	ProgressStateInProgress = ProgressState("in_progress")
	ProgressStateComplete   = ProgressState("complete")
	ProgressStateError      = ProgressState("error")
)
View Source
const (
	BACKUP_FILES_DIRECTORY = "BackupFiles"
)
View Source
const (
	MessageTypeError = MessageType("error")
)

Variables

This section is empty.

Functions

func CleanUpAllMounts

func CleanUpAllMounts() (err error)

func CreateDeltaBlockBackup

func CreateDeltaBlockBackup(backupName string, config *DeltaBackupConfig) (isIncremental bool, err error)

func CreateSingleFileBackup

func CreateSingleFileBackup(volume *Volume, snapshot *Snapshot, filePath, destURL string) (string, error)

func DecodeBackupURL

func DecodeBackupURL(backupURL string) (string, string, string, error)

func DeleteBackupVolume

func DeleteBackupVolume(volumeName string, destURL string) error

func DeleteDeltaBlockBackup

func DeleteDeltaBlockBackup(backupURL string) error

func DeleteSingleFileBackup

func DeleteSingleFileBackup(backupURL string) error

func EncodeBackupURL

func EncodeBackupURL(backupName, volumeName, destURL string) string

func GetBackupstoreBase

func GetBackupstoreBase() string

func GetLog

func GetLog() logrus.FieldLogger

func List

func List(volumeName, destURL string, volumeOnly bool) (map[string]*VolumeInfo, error)

func LoadConfigInBackupStore

func LoadConfigInBackupStore(driver BackupStoreDriver, filePath string, v interface{}) error

func RegisterDriver

func RegisterDriver(kind string, initFunc InitFunc) error

func RestoreDeltaBlockBackup

func RestoreDeltaBlockBackup(config *DeltaRestoreConfig) error

func RestoreDeltaBlockBackupIncrementally

func RestoreDeltaBlockBackupIncrementally(config *DeltaRestoreConfig) error

func RestoreSingleFileBackup

func RestoreSingleFileBackup(backupURL, path string) (string, error)

func SaveBackupStoreToLocalFile

func SaveBackupStoreToLocalFile(driver BackupStoreDriver, backupStoreFileURL, localFilePath string) error

func SaveConfigInBackupStore

func SaveConfigInBackupStore(driver BackupStoreDriver, filePath string, v interface{}) error

func SaveLocalFileToBackupStore

func SaveLocalFileToBackupStore(localFilePath, backupStoreFilePath string, driver BackupStoreDriver) error

func SetBackupstoreBase

func SetBackupstoreBase(base string)

Types

type Backup

type Backup struct {
	sync.Mutex
	Name              string
	VolumeName        string
	SnapshotName      string
	SnapshotCreatedAt string
	CreatedTime       string
	Size              int64 `json:",string"`
	Labels            map[string]string
	IsIncremental     bool
	CompressionMethod string

	ProcessingBlocks *ProcessingBlocks

	Blocks     []BlockMapping `json:",omitempty"`
	SingleFile BackupFile     `json:",omitempty"`
}

type BackupFile

type BackupFile struct {
	FilePath string
}

type BackupInfo

type BackupInfo struct {
	Name              string
	URL               string
	SnapshotName      string
	SnapshotCreated   string
	Created           string
	Size              int64 `json:",string"`
	Labels            map[string]string
	IsIncremental     bool
	CompressionMethod string `json:",omitempty"`

	VolumeName             string `json:",omitempty"`
	VolumeSize             int64  `json:",string,omitempty"`
	VolumeCreated          string `json:",omitempty"`
	VolumeBackingImageName string `json:",omitempty"`

	Messages map[MessageType]string
}

func InspectBackup

func InspectBackup(backupURL string) (*BackupInfo, error)

type BackupStoreDriver

type BackupStoreDriver interface {
	Kind() string
	GetURL() string
	FileExists(filePath string) bool
	FileSize(filePath string) int64
	FileTime(filePath string) time.Time     // Needs to be returned in UTC
	Remove(path string) error               // Behavior like "rm -rf"
	Read(src string) (io.ReadCloser, error) // Caller needs to close
	Write(dst string, rs io.ReadSeeker) error
	List(path string) ([]string, error) // Behavior like "ls", not like "find"
	Upload(src, dst string) error
	Download(src, dst string) error
}

func GetBackupStoreDriver

func GetBackupStoreDriver(destURL string) (BackupStoreDriver, error)

type Block

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

type BlockInfo

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

type BlockMapping

type BlockMapping struct {
	Offset        int64
	BlockChecksum string
}

type ConfigMetadata

type ConfigMetadata struct {
	ModificationTime time.Time
}

func GetConfigMetadata

func GetConfigMetadata(url string) (*ConfigMetadata, error)

type DeltaBackupConfig

type DeltaBackupConfig struct {
	BackupName      string
	Volume          *Volume
	Snapshot        *Snapshot
	DestURL         string
	DeltaOps        DeltaBlockBackupOperations
	Labels          map[string]string
	ConcurrentLimit int32
}

type DeltaBlockBackupOperations

type DeltaBlockBackupOperations interface {
	HasSnapshot(id, volumeID string) bool
	CompareSnapshot(id, compareID, volumeID string) (*Mappings, error)
	OpenSnapshot(id, volumeID string) error
	ReadSnapshot(id, volumeID string, start int64, data []byte) error
	CloseSnapshot(id, volumeID string) error
	UpdateBackupStatus(id, volumeID string, backupState string, backupProgress int, backupURL string, err string) error
}

type DeltaRestoreConfig

type DeltaRestoreConfig struct {
	BackupURL       string
	DeltaOps        DeltaRestoreOperations
	LastBackupName  string
	Filename        string
	ConcurrentLimit int32
}

type DeltaRestoreOperations

type DeltaRestoreOperations interface {
	UpdateRestoreStatus(snapshot string, restoreProgress int, err error)
}

type FileLock

type FileLock struct {
	Name     string
	Type     LockType
	Acquired bool
	// contains filtered or unexported fields
}

func New

func New(driver BackupStoreDriver, volumeName string, lockType LockType) (*FileLock, error)

func (*FileLock) Lock

func (lock *FileLock) Lock() error

func (*FileLock) String

func (lock *FileLock) String() string

func (*FileLock) Unlock

func (lock *FileLock) Unlock() error

type InitFunc

type InitFunc func(destURL string) (BackupStoreDriver, error)

type JobResult

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

type LockType

type LockType int
const BACKUP_LOCK LockType = 1
const DELETION_LOCK LockType = 2
const RESTORE_LOCK LockType = 1
const UNTYPED_LOCK LockType = 0

type Mapping

type Mapping struct {
	Offset int64
	Size   int64
}

type Mappings

type Mappings struct {
	Mappings  []Mapping
	BlockSize int64
}

type MessageType

type MessageType string

type ProcessingBlocks

type ProcessingBlocks struct {
	sync.Mutex
	// contains filtered or unexported fields
}

type ProgressState

type ProgressState string

type Snapshot

type Snapshot struct {
	Name        string
	CreatedTime string
}

type Volume

type Volume struct {
	Name                 string
	Size                 int64 `json:",string"`
	Labels               map[string]string
	CreatedTime          string
	LastBackupName       string
	LastBackupAt         string
	BlockCount           int64  `json:",string"`
	BackingImageName     string `json:",string"`
	BackingImageChecksum string `json:",string"`
	CompressionMethod    string `json:",string"`
	StorageClassName     string `json:",string"`
}

func LoadVolume

func LoadVolume(backupURL string) (*Volume, error)

type VolumeInfo

type VolumeInfo struct {
	Name           string
	Size           int64 `json:",string"`
	Labels         map[string]string
	Created        string
	LastBackupName string
	LastBackupAt   string
	DataStored     int64 `json:",string"`

	Messages map[MessageType]string

	Backups map[string]*BackupInfo `json:",omitempty"`

	BackingImageName     string
	BackingImageChecksum string
	StorageClassname     string
}

func InspectVolume

func InspectVolume(volumeURL string) (*VolumeInfo, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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