diff --git a/Makefile b/Makefile index e09f437..00d1cd6 100644 --- a/Makefile +++ b/Makefile @@ -24,7 +24,12 @@ endif .PHONY: build build: generate-examples go mod tidy - go build -ldflags "$(LINKMODE)" -tags 'osusergo netgo static_build' -o bin/backup-restore-sidecar github.com/metal-stack/backup-restore-sidecar/cmd + go build -ldflags "-X 'github.com/metal-stack/v.Version=$(VERSION)' \ + -X 'github.com/metal-stack/v.Revision=$(GITVERSION)' \ + -X 'github.com/metal-stack/v.GitSHA1=$(SHA)' \ + -X 'github.com/metal-stack/v.BuildDate=$(BUILDDATE)' \ + $(EXTLDFLAGS)" \ + -tags 'osusergo netgo static_build' -o bin/backup-restore-sidecar github.com/metal-stack/backup-restore-sidecar/cmd strip bin/backup-restore-sidecar .PHONY: test diff --git a/cmd/internal/database/localfs/localfs.go b/cmd/internal/database/localfs/localfs.go new file mode 100644 index 0000000..7ee4d22 --- /dev/null +++ b/cmd/internal/database/localfs/localfs.go @@ -0,0 +1,35 @@ +package localfs + +import "go.uber.org/zap" + +type LocalFS struct { + datadir string + log *zap.SugaredLogger +} + +func New(log *zap.SugaredLogger, datadir string) *LocalFS { + return &LocalFS{ + datadir: datadir, + log: log, + } +} + +func (l *LocalFS) Check() (bool, error) { + //ToDo: check if Datadir empty -> true + return true, nil +} + +func (l *LocalFS) Backup() error { + //ToDo: put Datadir into compressed archive + return nil +} + +func (l *LocalFS) Recover() error { + //ToDo: decompress archive into Datadir + return nil +} + +func (l *LocalFS) Probe() error { + //Nothing to do, not a real Database + return nil +} diff --git a/cmd/main.go b/cmd/main.go index a581268..008d778 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -9,6 +9,8 @@ import ( "os/signal" "strings" + "github.com/metal-stack/backup-restore-sidecar/cmd/internal/database/localfs" + v1 "github.com/metal-stack/backup-restore-sidecar/api/v1" "github.com/metal-stack/backup-restore-sidecar/cmd/internal/backup" "github.com/metal-stack/backup-restore-sidecar/cmd/internal/backup/providers" @@ -273,7 +275,7 @@ func init() { rootCmd.AddCommand(startCmd, waitCmd, restoreCmd, createBackupCmd) rootCmd.PersistentFlags().StringP(logLevelFlg, "", "info", "sets the application log level") - rootCmd.PersistentFlags().StringP(databaseFlg, "", "", "the kind of the database [postgres|rethinkdb|etcd|meilisearch|redis|keydb]") + rootCmd.PersistentFlags().StringP(databaseFlg, "", "", "the kind of the database [postgres|rethinkdb|etcd|meilisearch|redis|keydb|localfs]") rootCmd.PersistentFlags().StringP(databaseDatadirFlg, "", "", "the directory where the database stores its data in") err := viper.BindPFlags(rootCmd.PersistentFlags()) @@ -459,6 +461,12 @@ func initDatabase() error { if err != nil { return err } + case "localfs": + db = localfs.New( + logger.Named("localfs"), + datadir, + ) + default: return fmt.Errorf("unsupported database type: %s", dbString) }