diff --git a/pkg/backup/watch.go b/pkg/backup/watch.go index 8758fddc..db732884 100644 --- a/pkg/backup/watch.go +++ b/pkg/backup/watch.go @@ -91,7 +91,7 @@ func (b *Backuper) Watch(watchInterval, fullInterval, watchBackupNameTemplate, t if err != nil { return err } - backupTemplateNamePrepR := regexp.MustCompile(`\{type\}|\{time:[\S\s]+\}`) + backupTemplateNamePrepR := regexp.MustCompile(`{type}|{time:([^}]+)}`) backupTemplateNameR := regexp.MustCompile(backupTemplateNamePrepR.ReplaceAllString(backupTemplateName, `\S+`)) for _, remoteBackup := range remoteBackups { @@ -111,13 +111,17 @@ func (b *Backuper) Watch(watchInterval, fullInterval, watchBackupNameTemplate, t now := time.Now() timeBeforeDoBackup := int(b.cfg.General.WatchDuration.Seconds() - now.Sub(lastBackup).Seconds()) timeBeforeDoFullBackup := int(b.cfg.General.FullDuration.Seconds() - now.Sub(lastFullBackup).Seconds()) + b.log.Infof("Time before do backup %v", timeBeforeDoBackup) + b.log.Infof("Time before do full backup %v", timeBeforeDoFullBackup) if timeBeforeDoBackup > 0 && timeBeforeDoFullBackup > 0 { b.log.Infof("Wainting %d seconds until continue doing backups due watch interval", timeBeforeDoBackup) time.Sleep(b.cfg.General.WatchDuration - now.Sub(lastBackup)) } - lastBackup = time.Now() + now = time.Now() + lastBackup = now if b.cfg.General.FullDuration.Seconds()-time.Now().Sub(lastFullBackup).Seconds() <= 0 { backupType = "full" + lastFullBackup = now } else { backupType = "increment" }