Skip to content
This repository has been archived by the owner on Nov 3, 2022. It is now read-only.

Commit

Permalink
Merge pull request #99 from stefanprodan/mongo-4.2
Browse files Browse the repository at this point in the history
Update packages for MongoDB 4.2
  • Loading branch information
stefanprodan authored Jan 20, 2020
2 parents 9f5bac5 + 435123a commit 495e919
Show file tree
Hide file tree
Showing 30 changed files with 134 additions and 130 deletions.
13 changes: 6 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,27 +1,26 @@
FROM golang:1.13

# TODO: work out how to get this from version.go
ARG app_version=v0.0.0-dev
ARG VERSION

COPY . /go/src/github.com/stefanprodan/mgob

WORKDIR /go/src/github.com/stefanprodan/mgob

RUN CGO_ENABLED=0 GOOS=linux \
go build \
-ldflags "-X main.version=$app_version" \
-ldflags "-X main.version=$VERSION" \
-a -installsuffix cgo \
-o mgob github.com/stefanprodan/mgob/cmd/mgob

FROM alpine:3.9
FROM alpine:3.11

ARG BUILD_DATE
ARG VCS_REF
ARG VERSION

ENV MONGODB_TOOLS_VERSION 4.0.5-r0
ENV GOOGLE_CLOUD_SDK_VERSION 235.0.0
ENV AZURE_CLI_VERSION 2.0.58
ENV MONGODB_TOOLS_VERSION 4.2.1-r0
ENV GOOGLE_CLOUD_SDK_VERSION 276.0.0
ENV AZURE_CLI_VERSION 2.0.80
ENV PATH /root/google-cloud-sdk/bin:$PATH

LABEL org.label-schema.build-date=$BUILD_DATE \
Expand Down
12 changes: 10 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
SHELL:=/bin/bash

APP_VERSION?=1.0
APP_VERSION?=1.1

# build vars
BUILD_DATE:=$(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
Expand All @@ -14,6 +14,14 @@ TRAVIS:=$$(pwd)/test/travis
PACKAGES:=$(shell go list ./... | grep -v '/vendor/')
VETARGS:=-asmdecl -atomic -bool -buildtags -copylocks -methods -nilfunc -rangeloops -shift -structtags -unsafeptr

build:
@echo ">>> Building $(REPOSITORY)/mgob:$(APP_VERSION)"
@docker build \
--build-arg BUILD_DATE=$(BUILD_DATE) \
--build-arg VCS_REF=$(TRAVIS_COMMIT) \
--build-arg VERSION=$(APP_VERSION) \
-t $(REPOSITORY)/mgob:$(APP_VERSION) .

travis:
@echo ">>> Building mgob:$(APP_VERSION).$(TRAVIS_BUILD_NUMBER) image"
@docker build \
Expand Down Expand Up @@ -46,7 +54,7 @@ release:
@docker push $(REPOSITORY)/mgob:$(APP_VERSION)
@docker push $(REPOSITORY)/mgob:latest

run: build
run:
@echo ">>> Starting mgob container"
@docker run -dp 8090:8090 --name mgob-$(APP_VERSION) \
--restart unless-stopped \
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# mgob

[![Build Status](https://travis-ci.org/stefanprodan/mgob.svg?branch=master)](https://travis-ci.org/stefanprodan/mgob)
[![Docker Image](https://images.microbadger.com/badges/image/stefanprodan/mgob:edge.svg)](https://hub.docker.com/r/stefanprodan/mgob/)
[![Docker Pulls](https://img.shields.io/docker/pulls/stefanprodan/mgob)](https://hub.docker.com/r/stefanprodan/mgob/)

MGOB is a MongoDB backup automation tool built with golang.
MGOB is a MongoDB backup automation tool built with Go.

#### Features

Expand Down Expand Up @@ -33,6 +33,7 @@ Compatibility matrix:
`stefanprodan/mgob:0.9` | 3.4
`stefanprodan/mgob:0.10` | 3.6
`stefanprodan/mgob:1.0` | 4.0
`stefanprodan/mgob:1.1` | 4.2

Docker:

Expand Down
75 changes: 69 additions & 6 deletions cmd/mgob/mgob.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,23 @@ package main

import (
"os"
"os/signal"
"path"
"syscall"

log "github.com/Sirupsen/logrus"
"github.com/stefanprodan/mgob"
"github.com/stefanprodan/mgob/config"
log "github.com/sirupsen/logrus"
"github.com/urfave/cli"

"github.com/stefanprodan/mgob/pkg/api"
"github.com/stefanprodan/mgob/pkg/backup"
"github.com/stefanprodan/mgob/pkg/config"
"github.com/stefanprodan/mgob/pkg/db"
"github.com/stefanprodan/mgob/pkg/scheduler"
)

var (
appConfig = &config.AppConfig{}
version = "v1.1.0-dev"
)

func beforeApp(c *cli.Context) error {
Expand All @@ -33,7 +41,7 @@ func beforeApp(c *cli.Context) error {
func main() {
app := cli.NewApp()
app.Name = "mgob"
app.Version = mgob.Version
app.Version = version
app.Usage = "mongodb dockerized backup agent"
app.Action = start
app.Before = beforeApp
Expand Down Expand Up @@ -77,7 +85,7 @@ func main() {
}

func start(c *cli.Context) error {
log.Infof("mgob %v", mgob.Version)
log.Infof("mgob %v", version)

appConfig.LogLevel = c.String("LogLevel")
appConfig.JSONLog = c.Bool("JSONLog")
Expand All @@ -86,8 +94,63 @@ func start(c *cli.Context) error {
appConfig.StoragePath = c.String("StoragePath")
appConfig.TmpPath = c.String("TmpPath")
appConfig.DataPath = c.String("DataPath")
appConfig.Version = version

log.Infof("starting with config: %+v", appConfig)

info, err := backup.CheckMongodump()
if err != nil {
log.Fatal(err)
}
log.Info(info)

info, err = backup.CheckMinioClient()
if err != nil {
log.Fatal(err)
}
log.Info(info)

info, err = backup.CheckGCloudClient()
if err != nil {
log.Fatal(err)
}
log.Info(info)

info, err = backup.CheckAzureClient()
if err != nil {
log.Fatal(err)
}
log.Info(info)

plans, err := config.LoadPlans(appConfig.ConfigPath)
if err != nil {
log.Fatal(err)
}

store, err := db.Open(path.Join(appConfig.DataPath, "mgob.db"))
if err != nil {
log.Fatal(err)
}
statusStore, err := db.NewStatusStore(store)
if err != nil {
log.Fatal(err)
}
sch := scheduler.New(plans, appConfig, statusStore)
sch.Start()

server := &api.HttpServer{
Config: appConfig,
Stats: statusStore,
}
log.Infof("starting http server on port %v", appConfig.Port)
go server.Start(appConfig.Version)

// wait for SIGINT (Ctrl+C) or SIGTERM (docker stop)
sigChan := make(chan os.Signal, 1)
signal.Notify(sigChan, syscall.SIGINT, syscall.SIGTERM)
sig := <-sigChan

mgob.Start(appConfig)
log.Infof("shutting down %v signal received", sig)

return nil
}
75 changes: 0 additions & 75 deletions entry.go

This file was deleted.

3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ module github.com/stefanprodan/mgob
go 1.13

require (
github.com/Sirupsen/logrus v0.11.5
github.com/boltdb/bolt v1.3.1
github.com/codegangsta/inject v0.0.0-20150114235600-33e0aa1cb7c0 // indirect
github.com/codeskyblue/go-sh v0.0.0-20170112005953-b097669b1569
Expand All @@ -15,9 +14,9 @@ require (
github.com/pkg/sftp v1.10.1-0.20190523025818-e98a7bef6829
github.com/prometheus/client_golang v0.9.3
github.com/robfig/cron v1.0.1-0.20170309132418-df38d32658d8
github.com/sirupsen/logrus v1.4.2
github.com/urfave/cli v1.20.0
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793
golang.org/x/sys v0.0.0-20190124100055-b90733256f2e // indirect
golang.org/x/text v0.3.2 // indirect
gopkg.in/yaml.v2 v2.2.1
)
9 changes: 5 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
github.com/Sirupsen/logrus v0.11.5 h1:aIMrrsnipdTlAieMe7FC/iiuJ0+ELiXCT4YiVQiK9j8=
github.com/Sirupsen/logrus v0.11.5/go.mod h1:rmk17hk6i8ZSAJkSDa7nOxamrG+SP4P0mm+DAvExv4U=
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
Expand Down Expand Up @@ -31,6 +29,7 @@ github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5y
github.com/golang/protobuf v1.3.1 h1:YF8+flBXS5eO826T4nzqPrxfhQThhXl0YzfuUPu4SBg=
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/kr/fs v0.1.0 h1:Jskdu9ieNAYnjxsi0LbQp1ulIKZV1LAFgK1tWhpZgl8=
github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg=
Expand Down Expand Up @@ -62,6 +61,8 @@ github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40T
github.com/robfig/cron v1.0.1-0.20170309132418-df38d32658d8 h1:70QTOM3skvDpJG6xz4AVSU2l91+lu1nAP5qvZU7NhRc=
github.com/robfig/cron v1.0.1-0.20170309132418-df38d32658d8/go.mod h1:JGuDeoQd7Z6yL4zQhZ3OPEVHB7fL6Ka6skscFHfmt2k=
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4=
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
Expand All @@ -77,8 +78,8 @@ golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJ
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190124100055-b90733256f2e h1:3GIlrlVLfkoipSReOMNAgApI0ajnalyLa/EZHHca/XI=
golang.org/x/sys v0.0.0-20190124100055-b90733256f2e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190422165155-953cdadca894 h1:Cz4ceDQGXuKRnVBDTS23GTn/pU5OE2C0WrNTOYK1Uuc=
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
Expand Down
9 changes: 5 additions & 4 deletions api/backup.go → pkg/api/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ import (
"net/http"
"time"

log "github.com/Sirupsen/logrus"
"github.com/dustin/go-humanize"
"github.com/go-chi/chi"
"github.com/go-chi/render"
"github.com/stefanprodan/mgob/backup"
"github.com/stefanprodan/mgob/config"
"github.com/stefanprodan/mgob/notifier"
log "github.com/sirupsen/logrus"

"github.com/stefanprodan/mgob/pkg/backup"
"github.com/stefanprodan/mgob/pkg/config"
"github.com/stefanprodan/mgob/pkg/notifier"
)

func configCtx(data config.AppConfig) func(next http.Handler) http.Handler {
Expand Down
File renamed without changes.
7 changes: 4 additions & 3 deletions api/server.go → pkg/api/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ import (
"net/http"
"strings"

log "github.com/Sirupsen/logrus"
"github.com/go-chi/chi"
"github.com/go-chi/chi/middleware"
"github.com/stefanprodan/mgob/config"
"github.com/stefanprodan/mgob/db"
log "github.com/sirupsen/logrus"

"github.com/stefanprodan/mgob/pkg/config"
"github.com/stefanprodan/mgob/pkg/db"
)

type HttpServer struct {
Expand Down
3 changes: 2 additions & 1 deletion api/status.go → pkg/api/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import (

"github.com/go-chi/chi"
"github.com/go-chi/render"
"github.com/stefanprodan/mgob/db"

"github.com/stefanprodan/mgob/pkg/db"
)

type appStatus []*db.Status
Expand Down
File renamed without changes.
3 changes: 2 additions & 1 deletion backup/azure.go → pkg/backup/azure.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import (

"github.com/codeskyblue/go-sh"
"github.com/pkg/errors"
"github.com/stefanprodan/mgob/config"

"github.com/stefanprodan/mgob/pkg/config"
)

func azureUpload(file string, plan config.Plan) (string, error) {
Expand Down
5 changes: 3 additions & 2 deletions backup/backup.go → pkg/backup/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ import (
"path/filepath"
"time"

log "github.com/Sirupsen/logrus"
"github.com/codeskyblue/go-sh"
"github.com/pkg/errors"
"github.com/stefanprodan/mgob/config"
log "github.com/sirupsen/logrus"

"github.com/stefanprodan/mgob/pkg/config"
)

func Run(plan config.Plan, tmpPath string, storagePath string) (Result, error) {
Expand Down
File renamed without changes.
Loading

0 comments on commit 495e919

Please sign in to comment.