Skip to content

Commit

Permalink
Add: nfs backup
Browse files Browse the repository at this point in the history
Signed-off-by: sayedppqq <[email protected]>
  • Loading branch information
sayedppqq committed Apr 26, 2024
1 parent 2351b87 commit 0aa6b37
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 1 deletion.
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -285,3 +285,9 @@ unlink_libsodium:
build_client:
cd cmd/daemonclient && \
go build -o ../../bin/walg-daemon-client -ldflags "-s -w -X main.buildDate=`date -u +%Y.%m.%d_%H:%M:%S` -X main.gitRevision=`git rev-parse --short HEAD` -X main.version=`git tag -l --points-at HEAD`"


update: mongo_build
docker build --tag walg:2.0 /home/sayed/go/src/kubedb.dev/wal-g/main/mongo
docker tag walg:2.0 sayedppqq/walg:2.0
docker push sayedppqq/walg:2.0
19 changes: 18 additions & 1 deletion cmd/mongo/oplog_push.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package mongo
import (
"context"
"os"
"path"
"syscall"
"time"

Expand Down Expand Up @@ -73,7 +74,11 @@ func runOplogPush(ctx context.Context, pushArgs oplogPushRunArgs, statsArgs oplo
if err != nil {
return err
}
uplProvider.ChangeDirectory(models.OplogArchBasePath)
subDir := models.OplogArchBasePath
if pushArgs.dbProvider == "local" {
subDir = path.Join(pushArgs.dbPath, subDir)
}
uplProvider.ChangeDirectory(subDir)
uploader := archive.NewStorageUploader(uplProvider)
uploader.SetKubeClient(pushArgs.kubeClient)
uploader.SetSnapshot(snapshotName, snapshotNamespace)
Expand Down Expand Up @@ -146,6 +151,8 @@ type oplogPushRunArgs struct {
primaryWaitTimeout time.Duration
lwUpdate time.Duration
kubeClient controllerclient.Client
dbProvider string
dbPath string
}

func buildOplogPushRunArgs() (args oplogPushRunArgs, err error) {
Expand All @@ -164,6 +171,16 @@ func buildOplogPushRunArgs() (args oplogPushRunArgs, err error) {
return
}

args.dbProvider, err = internal.GetRequiredSetting(internal.MongoDBProvider)
if err != nil {
return
}

args.dbPath, err = internal.GetRequiredSetting(internal.MongoDBPath)
if err != nil {
return
}

args.primaryWait, err = internal.GetBoolSettingDefault(internal.OplogPushWaitForBecomePrimary, false)
if err != nil {
return
Expand Down
2 changes: 2 additions & 0 deletions internal/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ const (
ProfileMode = "PROFILE_MODE"
ProfilePath = "PROFILE_PATH"

MongoDBProvider = "MONGODB_PROVIDER"
MongoDBPath = "MONGODB_PATH"
MongoDBUriSetting = "MONGODB_URI"
MongoDBLastWriteUpdateInterval = "MONGODB_LAST_WRITE_UPDATE_INTERVAL"
MongoDBRestoreDisableHostResetup = "MONGODB_RESTORE_DISABLE_HOST_RESETUP"
Expand Down
13 changes: 13 additions & 0 deletions main/mongo/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM debian:bookworm

RUN set -x \
&& apt-get update \
&& apt-get install -y --no-install-recommends apt-transport-https ca-certificates curl;

#RUN curl -LO https://fastdl.mongodb.org/tools/db/mongodb-database-tools-ubuntu2004-x86_64-100.5.4.tgz \
# && tar -zxvf mongodb-database-tools-ubuntu2004-x86_64-100.5.4.tgz \
# && cp -r ./mongodb-database-tools-ubuntu2004-x86_64-100.5.4/bin/* /bin/ ;

COPY wal-g /bin/wal-g

ENTRYPOINT [ "/bin/wal-g" ]
1 change: 1 addition & 0 deletions pkg/storages/fs/folder.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ func (folder *Folder) Exists(objectRelativePath string) (bool, error) {

func (folder *Folder) GetSubFolder(subFolderRelativePath string) storage.Folder {
sf := NewFolder(folder.rootPath, path.Join(folder.subpath, subFolderRelativePath))
fmt.Println("---------------", sf)
_ = sf.EnsureExists()

// This is something unusual when we cannot be sure that our subfolder exists in FS
Expand Down

0 comments on commit 0aa6b37

Please sign in to comment.