maxisam / mgob

MongoDB dockerized backup agent. Runs schedule backups with retention, S3 & SFTP upload, notifications, instrumentation with Prometheus and more.
https://maxisam.github.io/mgob/
MIT License
137 stars 19 forks source link

Error running backup #61

Closed ChrisDoernen closed 1 year ago

ChrisDoernen commented 1 year ago

Hi,

I get an error when the backup is running (stack trace below).

I don't know Go, but I believe the issue is the evaluation of this regex.

The output of running the mongodump command inside the container contains the following lines before the error is thrown:

basmongodump --gzip --host *** --port 27017 -u *** -p *** --db minds-q --authenticationDatabase admin
2023-05-26T10:03:36.578+0000    writing minds-q.fs.files to dump/minds-q/fs.files.bson.gz
2023-05-26T10:03:36.579+0000    writing minds-q.fs.chunks to dump/minds-q/fs.chunks.bson.gz
2023-05-26T10:03:36.586+0000    done dumping minds-q.fs.files (1 document)
2023-05-26T10:03:36.595+0000    done dumping minds-q.fs.chunks (1 document)

The collections are MongoDB collections to store files. Maybe the regex can't handle two dots in the collection name?

Help is much appreciated. This tool is really useful, I'd be very nice to use it!

Best

Chris

Stack trace:

2023/05/26 09:59:31 http: panic serving 172.24.0.2:39012: runtime error: slice bounds out of range [-1:]
goroutine 68 [running]:
net/http.(*conn).serve.func1()
        /usr/local/go/src/net/http/server.go:1850 +0xbf
panic({0xc05c20, 0xc0002cc1c8})
        /usr/local/go/src/runtime/panic.go:890 +0x262
github.com/go-chi/chi/middleware.prettyStack.decorateFuncCallLine({}, {0xc000410178, 0x1f}, 0xd9?, 0x6)
        /go/pkg/mod/github.com/go-chi/chi@v1.5.4/middleware/recoverer.go:130 +0x545
github.com/go-chi/chi/middleware.prettyStack.decorateLine({}, {0xc000410178?, 0xc0002c2c00?}, 0x8?, 0x1?)
        /go/pkg/mod/github.com/go-chi/chi@v1.5.4/middleware/recoverer.go:106 +0x15d
github.com/go-chi/chi/middleware.prettyStack.parse({}, {0xc0002ff000, 0xec4, 0xad23bf?}, {0xc05c20, 0xc0002cc198})
        /go/pkg/mod/github.com/go-chi/chi@v1.5.4/middleware/recoverer.go:89 +0x4d5
github.com/go-chi/chi/middleware.PrintPrettyStack({0xc05c20, 0xc0002cc198})
        /go/pkg/mod/github.com/go-chi/chi@v1.5.4/middleware/recoverer.go:46 +0x45
github.com/go-chi/chi/middleware.Recoverer.func1.1()
        /go/pkg/mod/github.com/go-chi/chi@v1.5.4/middleware/recoverer.go:30 +0xdd
panic({0xc05c20, 0xc0002cc198})
        /usr/local/go/src/runtime/panic.go:884 +0x212
github.com/stefanprodan/mgob/pkg/backup.getDumpedDocMap({0xc000282800, 0x3ef})
        /go/src/github.com/stefanprodan/mgob/pkg/backup/local.go:98 +0x245
github.com/stefanprodan/mgob/pkg/backup.dump({{0xc0002cc038, 0x5}, {{0xc0002922b8, 0x7}, {0xc000292290, 0xc}, {0x0, 0x0}, {0xc0002cc0a8, 0x18}, ...}, ...}, ...)
        /go/src/github.com/stefanprodan/mgob/pkg/backup/local.go:70 +0x630
github.com/stefanprodan/mgob/pkg/backup.Run({{0xc0002cc038, 0x5}, {{0xc0002922b8, 0x7}, {0xc000292290, 0xc}, {0x0, 0x0}, {0xc0002cc0a8, 0x18}, ...}, ...}, ...)
        /go/src/github.com/stefanprodan/mgob/pkg/backup/backup.go:21 +0x12d
github.com/stefanprodan/mgob/pkg/api.postBackup({0x7fac3927a9f8, 0xc0002abf00}, 0xc0002c6400)
        /go/src/github.com/stefanprodan/mgob/pkg/api/backup.go:42 +0x428
net/http.HandlerFunc.ServeHTTP(0xb85fe0?, {0x7fac3927a9f8?, 0xc0002abf00?}, 0xc0002921c6?)
        /usr/local/go/src/net/http/server.go:2109 +0x2f
github.com/go-chi/chi.(*Mux).routeHTTP(0xc000284600, {0x7fac3927a9f8, 0xc0002abf00}, 0xc0002c6400)
        /go/pkg/mod/github.com/go-chi/chi@v1.5.4/mux.go:436 +0x1f9
net/http.HandlerFunc.ServeHTTP(0xe19ef8?, {0x7fac3927a9f8?, 0xc0002abf00?}, 0xe11fc0?)
        /usr/local/go/src/net/http/server.go:2109 +0x2f
github.com/stefanprodan/mgob/pkg/api.configCtx.func1.1({0x7fac3927a9f8, 0xc0002abf00}, 0xc0002c6200)
        /go/src/github.com/stefanprodan/mgob/pkg/api/backup.go:24 +0x2f6
net/http.HandlerFunc.ServeHTTP(0xc000403798?, {0x7fac3927a9f8?, 0xc0002abf00?}, 0xc000403778?)
        /usr/local/go/src/net/http/server.go:2109 +0x2f
github.com/go-chi/chi.(*Mux).ServeHTTP(0xc000284600, {0x7fac3927a9f8, 0xc0002abf00}, 0xc0002c6200)
        /go/pkg/mod/github.com/go-chi/chi@v1.5.4/mux.go:70 +0x371
github.com/go-chi/chi.(*Mux).Mount.func1({0x7fac3927a9f8, 0xc0002abf00}, 0xc0002c6200)
        /go/pkg/mod/github.com/go-chi/chi@v1.5.4/mux.go:311 +0x19c
net/http.HandlerFunc.ServeHTTP(0xb85fe0?, {0x7fac3927a9f8?, 0xc0002abf00?}, 0xc0002a0045?)
        /usr/local/go/src/net/http/server.go:2109 +0x2f
github.com/go-chi/chi.(*Mux).routeHTTP(0xc000284120, {0x7fac3927a9f8, 0xc0002abf00}, 0xc0002c6200)
        /go/pkg/mod/github.com/go-chi/chi@v1.5.4/mux.go:436 +0x1f9
net/http.HandlerFunc.ServeHTTP(0xc0002c6100?, {0x7fac3927a9f8?, 0xc0002abf00?}, 0x8?)
        /usr/local/go/src/net/http/server.go:2109 +0x2f
github.com/go-chi/chi/middleware.RequestLogger.func1.1({0xe19338, 0xc0002d0000}, 0xc0002c6100)
        /go/pkg/mod/github.com/go-chi/chi@v1.5.4/middleware/logger.go:57 +0x3aa
net/http.HandlerFunc.ServeHTTP(0x0?, {0xe19338?, 0xc0002d0000?}, 0xf8?)
        /usr/local/go/src/net/http/server.go:2109 +0x2f
github.com/go-chi/chi/middleware.Recoverer.func1({0xe19338?, 0xc0002d0000?}, 0x129e701?)
        /go/pkg/mod/github.com/go-chi/chi@v1.5.4/middleware/recoverer.go:37 +0x83
net/http.HandlerFunc.ServeHTTP(0xe19e50?, {0xe19338?, 0xc0002d0000?}, 0x129e7d0?)
        /usr/local/go/src/net/http/server.go:2109 +0x2f
github.com/go-chi/chi.(*Mux).ServeHTTP(0xc000284120, {0xe19338, 0xc0002d0000}, 0xc0002c6000)
        /go/pkg/mod/github.com/go-chi/chi@v1.5.4/mux.go:87 +0x32a
net/http.serverHandler.ServeHTTP({0xc000288d80?}, {0xe19338, 0xc0002d0000}, 0xc0002c6000)
        /usr/local/go/src/net/http/server.go:2947 +0x30c
net/http.(*conn).serve(0xc0002879a0, {0xe19ef8, 0xc000288c90})
        /usr/local/go/src/net/http/server.go:1991 +0x607
created by net/http.(*Server).Serve
        /usr/local/go/src/net/http/server.go:3102 +0x4db
ChrisDoernen commented 1 year ago

It seems like the problem is a dash in the database name. After renaming ("minds-q" to "mindsQ"), the backup did run.

maxisam commented 1 year ago

Thanks for reporting it. I will find some time to fix it. Thanks!

maxisam commented 1 year ago

it is fixed in #70, thx for reporting !