Documentation
¶
Overview ¶
Package backup 实现定时配置备份:按 cron 表达式打包全部配置,写入本地目录或存储挂载中的挂载点 (本地目录、WebDAV),支持口令加密与按数量保留,并在成功或失败时发布通知事件。
Index ¶
Constants ¶
const ID = "backup"
ID 是模块标识。
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LocalFile ¶
type LocalFile struct {
Name string `json:"name"`
Size int64 `json:"size"`
ModTime time.Time `json:"modTime"`
}
LocalFile 是本地备份目录中的一个文件。
type Module ¶
type Module struct {
// contains filtered or unexported fields
}
Module 是备份模块。
type Result ¶
type Result struct {
Target string `json:"target"`
OK bool `json:"ok"`
File string `json:"file,omitempty"`
Error string `json:"error,omitempty"`
Pruned int `json:"pruned,omitempty"`
}
Result 是一个目的地在一次备份中的结果。
type Settings ¶
type Settings struct {
Enable bool `json:"enable"`
// Schedule 为 5 段 cron 表达式或 @daily 等描述符
Schedule string `json:"schedule"`
// Keep 为每个目的地保留的备份数量
Keep int `json:"keep"`
// Password 非空时备份被加密;恢复时需要提供同一口令
Password string `json:"password"`
// LocalEnable 决定是否写入配置目录下的 backups 子目录
LocalEnable bool `json:"localEnable"`
}
Settings 是定时备份的全局设置。
type Status ¶
type Status struct {
Running bool `json:"running"`
LastRun time.Time `json:"lastRun,omitzero"`
NextRun time.Time `json:"nextRun,omitzero"`
// Manual 表示最近一次由手动触发
Manual bool `json:"manual"`
Results []Result `json:"results"`
}
Status 是最近一次备份的概况。
type Storage ¶
type Storage interface {
MountList() []storage.MountInfo
PutFile(mount, dir, name string, data []byte) error
ListNames(mount, dir string) ([]string, error)
RemoveFile(mount, p string) error
}
Storage 由存储挂载模块实现,备份通过它写入挂载点。