Documentation
¶
Overview ¶
Package labelmanager contains a store to manage retention of backups through "labels" assigned in a specific format
Index ¶
- Variables
- type Manager
- func (m Manager) Add(entryName string) error
- func (m Manager) CleanRetentions()
- func (m Manager) GetClosestOlderBackup(pointInTime time.Time) (string, error)
- func (m Manager) GetRetainedEntries() []string
- func (m Manager) GetUnretainedEntries() []string
- func (m Manager) IsKnown(entryName string) bool
- func (m Manager) IsRetained(entryName string) bool
- func (m Manager) Remove(entryName string)
- func (m Manager) Save(dest io.Writer) error
- type RetentionConfig
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNoLabelsAdded signalizes when adding an entry all possible // labels were already present and the entry has not been added ErrNoLabelsAdded = errors.New("no labels were available to add") // ErrNoBackupFound signalizes there was no backup older than the // given point-in-time ErrNoBackupFound = errors.New("no backup found for point-in-time") )
var DefaultRetentionConfig = map[string]time.Duration{ "%Y-%m": durTwelveMonths, "%Y-w%V": durOneMonth, "%Y-%m-%d": durOneWeek, "%Y-%m-%dT%H": durOneDay, "%Y-%m-%dT%H-%M-%S": time.Hour, }
DefaultRetentionConfig defines a two-year retention schema with 24 hourly, 7 daily, 4 weekly and 12 monthly backups. Other backups are held one hour.
Functions ¶
This section is empty.
Types ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager is a helper to organize and book-keep the entries based on a Grandfather-Father-Son principle
func New ¶
func New(labelStorage io.Reader, retention RetentionConfig) (*Manager, error)
New creates a new Manager configured with the baseDir and the RetentionConfig defining how long to keep backups
if labelStorage is nil, an empty manager will be initialized if retention is nil, the DefaultRetentionConfig will be used
func (Manager) Add ¶
Add adds a new backup to the manager. When adding it is assigned labels defined by the RetentionConfig in case they are not already assigned to any other backup. This ensures the generations are kept for as long as the RetentionConfig defines
Returns ErrNoLabelsAdded in case all possible labels were already set. In this case the entry is not added to the Manager / store.
func (Manager) CleanRetentions ¶
func (m Manager) CleanRetentions()
CleanRetentions iterates all labels present and removes labels no longer covered by their retention duration
func (Manager) GetClosestOlderBackup ¶
GetClosestOlderBackup retrieves the backup closest to the given point in time but being created BEFORE that point in time
Returns ErrNoBackupFound when there is no backup to return
func (Manager) GetRetainedEntries ¶
GetRetainedEntries lists all entries which match IsRetained
func (Manager) GetUnretainedEntries ¶
GetUnretainedEntries lists all entries which do not match IsRetained
func (Manager) IsRetained ¶
IsRetained checks whether there are still valid labels on the backup and therefore whether it should be retained or not. Before using IsRetained a CleanRetentions run should be executed in order to clean timed out labels.
type RetentionConfig ¶
RetentionConfig specifies strftime formats and their respective retention periods. Ths is used to generate labels for entries and therefore define how long the entry is retained on disk