Skip to content

Commit

Permalink
chore: refactor oplog interface to abstract storage (#429)
Browse files Browse the repository at this point in the history
  • Loading branch information
garethgeorge authored Aug 26, 2024
1 parent 1879ddf commit 79cae5b
Show file tree
Hide file tree
Showing 36 changed files with 2,296 additions and 2,008 deletions.
7 changes: 5 additions & 2 deletions cmd/backrest/backrest.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"github.com/garethgeorge/backrest/internal/config"
"github.com/garethgeorge/backrest/internal/env"
"github.com/garethgeorge/backrest/internal/oplog"
"github.com/garethgeorge/backrest/internal/oplog/bboltstore"
"github.com/garethgeorge/backrest/internal/orchestrator"
"github.com/garethgeorge/backrest/internal/resticinstaller"
"github.com/garethgeorge/backrest/internal/rotatinglog"
Expand Down Expand Up @@ -66,15 +67,17 @@ func main() {

// Create / load the operation log
oplogFile := path.Join(env.DataDir(), "oplog.boltdb")
oplog, err := oplog.NewOpLog(oplogFile)
opstore, err := bboltstore.NewBboltStore(oplogFile)
if err != nil {
if !errors.Is(err, bbolt.ErrTimeout) {
zap.S().Fatalf("timeout while waiting to open database, is the database open elsewhere?")
}
zap.S().Warnf("operation log may be corrupted, if errors recur delete the file %q and restart. Your backups stored in your repos are safe.", oplogFile)
zap.S().Fatalf("error creating oplog : %v", err)
}
defer oplog.Close()
defer opstore.Close()

oplog := oplog.NewOpLog(opstore)

// Create rotating log storage
logStore := rotatinglog.NewRotatingLog(path.Join(env.DataDir(), "rotatinglogs"), 14) // 14 days of logs
Expand Down
85 changes: 74 additions & 11 deletions gen/go/types/value.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 79cae5b

Please sign in to comment.