mirror of
https://github.com/cupcakearmy/autorestic.git
synced 2024-11-05 13:14:48 +01:00
23 lines
570 B
Go
23 lines
570 B
Go
package metadata
|
|
|
|
import (
|
|
"regexp"
|
|
"strings"
|
|
)
|
|
|
|
type parentSnapshotIDExtractor struct {
|
|
re *regexp.Regexp
|
|
}
|
|
|
|
func (e parentSnapshotIDExtractor) Matches(line string) bool {
|
|
return e.re.MatchString(line)
|
|
}
|
|
func (e parentSnapshotIDExtractor) Extract(metadata *BackupLogMetadata, line string) {
|
|
// Sample line: "using parent snapshot c65d9310"
|
|
metadata.ParentSnapshotID = strings.TrimSpace(e.re.ReplaceAllString(line, ""))
|
|
}
|
|
|
|
func NewParentSnapshotIDExtractor() MetadatExtractor {
|
|
return parentSnapshotIDExtractor{regexp.MustCompile(`(?i)^using parent snapshot`)}
|
|
}
|