backup

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2017 License: MIT Imports: 14 Imported by: 0

README

备份功能

备份使用的后台Storage以插件的形式集成到功能中

实现的driver必须满足下面接口:

type Storage interface {
	// the storage's name
	Name() string

	Upload(file string) error

	Download(file, localFile string) error

	List() ([]string, error)

	Delete(file string) error
}

实现Storage接口,然后调用crond.Register()注册到crond服务上.

Documentation

Index

Constants

View Source
const (
	MODE_FULL      = "full"
	MODE_INCREMENT = "increment"

	StateBackuping  = "backuping"
	StateRecovering = "recovering"
	StateFree       = "free"
)
View Source
const (
	APP_ROOT = "/lain/app"
)

Variables

This section is empty.

Functions

func Delete

func Delete(name string) error

func FileList

func FileList(name string) ([]os.FileInfo, error)

func Init

func Init(localip, driver string)

backup task initialize

func Register

func Register(driver Storage)

Storage driver register

func Release

func Release()

release the backup

Types

type BackupStats

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

func (*BackupStats) Free

func (b *BackupStats) Free(path string)

func (*BackupStats) Set

func (b *BackupStats) Set(path, stat string) error

type Entity

type Entity struct {
	Mode    string    `json:"mode"`
	Source  string    `json:"source"`
	Volume  string    `json:"volume"`
	Name    string    `json:"name"`
	Server  string    `json:"server"`
	Size    uint64    `json:"size"`
	Created time.Time `json:"created"`

	Containers []string `json:"containers"`
	InstanceNo int      `json:"instanceNo"`
	// contains filtered or unexported fields
}

A Entity is a backup

func Info

func Info(name string) (Entity, error)

func List

func List(dir ...string) ([]Entity, error)

func NewEntity

func NewEntity(src, archive string, instanceNo int, containers []string, volume string, mode string) *Entity

func (*Entity) Backup

func (ent *Entity) Backup(driver Storage) error

func (*Entity) IncrementBackup

func (ent *Entity) IncrementBackup() error

func (*Entity) IncrementRecover

func (ent *Entity) IncrementRecover(files []string) error

func (*Entity) Recover

func (ent *Entity) Recover(driver Storage, ns, file string) error

type Meta

type Meta struct {
	Entities map[string][]Entity
	// contains filtered or unexported fields
}

func NewMeta

func NewMeta(backend Storage, namespace string) *Meta

func (*Meta) Add

func (meta *Meta) Add(ent Entity)

func (*Meta) Array

func (meta *Meta) Array(src ...string) []Entity

func (*Meta) Delete

func (meta *Meta) Delete(name string)

func (*Meta) Get

func (meta *Meta) Get(name string) *Entity

func (*Meta) LoadFromBackend

func (meta *Meta) LoadFromBackend() error

func (*Meta) Set

func (meta *Meta) Set(src string, ents []Entity)

func (*Meta) Sync

func (meta *Meta) Sync() error

type Storage

type Storage interface {
	// the storage's name
	Name() string

	Upload(reader io.Reader, dest string) error

	Download(writer io.Writer, src string) error

	List(dir string) ([]os.FileInfo, error)

	Delete(file string) error

	FileInfo(name string) (os.FileInfo, error)

	Rsync(src, dest string) error
}

Directories

Path Synopsis
drivers

Jump to

Keyboard shortcuts

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