From a34b38e7317b42a43098c536335cb2b3532b0edf Mon Sep 17 00:00:00 2001 From: Yannik Bramkamp Date: Tue, 5 Nov 2024 09:44:42 +0100 Subject: [PATCH] log the error that triggers panic --- cmd/mongodump.go | 3 +++ cmd/mongorestore.go | 3 +++ cmd/mysqldump.go | 3 +++ cmd/mysqlrestore.go | 2 ++ cmd/pgdump.go | 3 +++ cmd/pgrestore.go | 3 +++ cmd/psql.go | 3 +++ cmd/redisdump.go | 3 +++ cmd/tar.go | 3 +++ cmd/tarrestore.go | 3 +++ 10 files changed, 29 insertions(+) diff --git a/cmd/mongodump.go b/cmd/mongodump.go index fe1e858..6ffeb06 100644 --- a/cmd/mongodump.go +++ b/cmd/mongodump.go @@ -3,6 +3,8 @@ package cmd import ( "context" + "github.com/sirupsen/logrus" + "github.com/mittwald/brudi/pkg/source" "github.com/spf13/cobra" @@ -21,6 +23,7 @@ var ( err := source.DoBackupForKind(ctx, mongodump.Kind, cleanup, useRestic, useResticForget) if err != nil { + logrus.WithError(err).Error("Failed to backup database") panic(err) } }, diff --git a/cmd/mongorestore.go b/cmd/mongorestore.go index 5680218..e901043 100644 --- a/cmd/mongorestore.go +++ b/cmd/mongorestore.go @@ -3,6 +3,8 @@ package cmd import ( "context" + "github.com/sirupsen/logrus" + "github.com/mittwald/brudi/pkg/source" "github.com/spf13/cobra" @@ -21,6 +23,7 @@ var ( err := source.DoRestoreForKind(ctx, mongorestore.Kind, cleanup, useRestic, useResticForget) if err != nil { + logrus.WithError(err).Error("Failed to restore database") panic(err) } }, diff --git a/cmd/mysqldump.go b/cmd/mysqldump.go index 41f6126..82e2a77 100644 --- a/cmd/mysqldump.go +++ b/cmd/mysqldump.go @@ -3,6 +3,8 @@ package cmd import ( "context" + "github.com/sirupsen/logrus" + "github.com/mittwald/brudi/pkg/source" "github.com/mittwald/brudi/pkg/source/mysqldump" @@ -20,6 +22,7 @@ var ( err := source.DoBackupForKind(ctx, mysqldump.Kind, cleanup, useRestic, useResticForget) if err != nil { + logrus.WithError(err).Error("Failed to backup database") panic(err) } }, diff --git a/cmd/mysqlrestore.go b/cmd/mysqlrestore.go index f76b660..b462152 100644 --- a/cmd/mysqlrestore.go +++ b/cmd/mysqlrestore.go @@ -3,6 +3,7 @@ package cmd import ( "context" + "github.com/sirupsen/logrus" "github.com/spf13/cobra" "github.com/mittwald/brudi/pkg/source" @@ -20,6 +21,7 @@ var ( err := source.DoRestoreForKind(ctx, mysqlrestore.Kind, cleanup, useRestic, useResticForget) if err != nil { + logrus.WithError(err).Error("Failed to restore database") panic(err) } }, diff --git a/cmd/pgdump.go b/cmd/pgdump.go index 15f8256..1cb5e54 100644 --- a/cmd/pgdump.go +++ b/cmd/pgdump.go @@ -3,6 +3,8 @@ package cmd import ( "context" + "github.com/sirupsen/logrus" + "github.com/mittwald/brudi/pkg/source/pgdump" "github.com/spf13/cobra" @@ -21,6 +23,7 @@ var ( err := source.DoBackupForKind(ctx, pgdump.Kind, cleanup, useRestic, useResticForget) if err != nil { + logrus.WithError(err).Error("Failed to backup database") panic(err) } }, diff --git a/cmd/pgrestore.go b/cmd/pgrestore.go index bd12f83..adebb39 100644 --- a/cmd/pgrestore.go +++ b/cmd/pgrestore.go @@ -3,6 +3,8 @@ package cmd import ( "context" + "github.com/sirupsen/logrus" + "github.com/mittwald/brudi/pkg/source" "github.com/spf13/cobra" @@ -21,6 +23,7 @@ var ( err := source.DoRestoreForKind(ctx, pgrestore.Kind, cleanup, useRestic, useResticForget) if err != nil { + logrus.WithError(err).Error("Failed to restore database") panic(err) } }, diff --git a/cmd/psql.go b/cmd/psql.go index 330c914..68f4db8 100644 --- a/cmd/psql.go +++ b/cmd/psql.go @@ -3,6 +3,8 @@ package cmd import ( "context" + "github.com/sirupsen/logrus" + "github.com/mittwald/brudi/pkg/source" "github.com/mittwald/brudi/pkg/source/psql" @@ -20,6 +22,7 @@ var ( err := source.DoRestoreForKind(ctx, psql.Kind, cleanup, useRestic, useResticForget) if err != nil { + logrus.WithError(err).Error("Failed to restore database") panic(err) } }, diff --git a/cmd/redisdump.go b/cmd/redisdump.go index e400f40..83225e9 100644 --- a/cmd/redisdump.go +++ b/cmd/redisdump.go @@ -3,6 +3,8 @@ package cmd import ( "context" + "github.com/sirupsen/logrus" + "github.com/mittwald/brudi/pkg/source/redisdump" "github.com/mittwald/brudi/pkg/source" @@ -21,6 +23,7 @@ var ( err := source.DoBackupForKind(ctx, redisdump.Kind, cleanup, useRestic, useResticForget) if err != nil { + logrus.WithError(err).Error("Failed to backup database") panic(err) } }, diff --git a/cmd/tar.go b/cmd/tar.go index ff4f5a4..404c34a 100644 --- a/cmd/tar.go +++ b/cmd/tar.go @@ -3,6 +3,8 @@ package cmd import ( "context" + "github.com/sirupsen/logrus" + "github.com/mittwald/brudi/pkg/source/tar" "github.com/mittwald/brudi/pkg/source" @@ -21,6 +23,7 @@ var ( err := source.DoBackupForKind(ctx, tar.Kind, cleanup, useRestic, useResticForget) if err != nil { + logrus.WithError(err).Error("Failed to backup database") panic(err) } }, diff --git a/cmd/tarrestore.go b/cmd/tarrestore.go index f66b2c9..3c0ab3f 100644 --- a/cmd/tarrestore.go +++ b/cmd/tarrestore.go @@ -3,6 +3,8 @@ package cmd import ( "context" + "github.com/sirupsen/logrus" + "github.com/mittwald/brudi/pkg/source" "github.com/mittwald/brudi/pkg/source/tarrestore" @@ -20,6 +22,7 @@ var ( err := source.DoRestoreForKind(ctx, tarrestore.Kind, cleanup, useRestic, useResticForget) if err != nil { + logrus.WithError(err).Error("Failed to restore database") panic(err) } },