Skip to content

Commit a293997

Browse files
committed
add automatic database backups to storagebox
1 parent c9788d0 commit a293997

6 files changed

Lines changed: 140 additions & 22 deletions

File tree

cmd/certmaker/main.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"time"
1212

1313
"github.com/KaiserWerk/CertMaker/internal/assets"
14+
"github.com/KaiserWerk/CertMaker/internal/backup"
1415
"github.com/KaiserWerk/CertMaker/internal/certmaker"
1516
"github.com/KaiserWerk/CertMaker/internal/configuration"
1617
"github.com/KaiserWerk/CertMaker/internal/dbservice"
@@ -27,7 +28,7 @@ var (
2728
VersionDate = "0000-00-00 00:00:00"
2829

2930
configFile = flag.String("config", "config.yaml", "The configuration file to use")
30-
logPath = flag.String("logpath", ".", "The path to place log files in")
31+
logPath = flag.String("logpath", ".", "The path to place log files at")
3132
port = flag.String("port", "8880", "The port to run at")
3233
useUi = flag.Bool("ui", true, "Adds a simple UI for certificate and instance management")
3334
)
@@ -59,6 +60,10 @@ func main() {
5960
return
6061
}
6162

63+
ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt)
64+
defer cancel()
65+
go backup.StartMakingBackups(ctx, config)
66+
6267
// create new session manager
6368
sessMgr := sessionstore.NewManager("CM_SESS")
6469
// create new certmaker instance and set up CA if necessary
@@ -77,9 +82,6 @@ func main() {
7782

7883
router := setupRoutes(config, logger, ds, sessMgr, cm, *useUi)
7984

80-
ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt)
81-
defer cancel()
82-
8385
host := fmt.Sprintf(":%s", *port)
8486
srv := &http.Server{
8587
Addr: host,

go.mod

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
module github.com/KaiserWerk/CertMaker
22

3-
go 1.24
3+
go 1.25.1
44

55
require (
66
github.com/KaiserWerk/go-log-rotator v0.0.0-20220120120752-c9b4f0acc247
77
github.com/KaiserWerk/sessionstore v1.0.1
8+
github.com/KaiserWerk/sqldump v0.0.3
89
github.com/gorilla/mux v1.8.0
910
github.com/sirupsen/logrus v1.8.1
10-
golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e
11+
golang.org/x/crypto v0.42.0
1112
gopkg.in/yaml.v2 v2.4.0
1213
gorm.io/driver/mysql v1.1.0
1314
gorm.io/driver/postgres v1.1.0
@@ -17,8 +18,10 @@ require (
1718
)
1819

1920
require (
21+
filippo.io/edwards25519 v1.1.0 // indirect
22+
github.com/JamesStewy/go-mysqldump v0.2.2 // indirect
2023
github.com/denisenkom/go-mssqldb v0.10.0 // indirect
21-
github.com/go-sql-driver/mysql v1.6.0 // indirect
24+
github.com/go-sql-driver/mysql v1.9.3 // indirect
2225
github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe // indirect
2326
github.com/jackc/chunkreader/v2 v2.0.1 // indirect
2427
github.com/jackc/pgconn v1.8.1 // indirect
@@ -30,7 +33,9 @@ require (
3033
github.com/jackc/pgx/v4 v4.11.0 // indirect
3134
github.com/jinzhu/inflection v1.0.0 // indirect
3235
github.com/jinzhu/now v1.1.2 // indirect
36+
github.com/kr/fs v0.1.0 // indirect
3337
github.com/mattn/go-sqlite3 v1.14.5 // indirect
34-
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1 // indirect
35-
golang.org/x/text v0.3.6 // indirect
38+
github.com/pkg/sftp v1.13.9 // indirect
39+
golang.org/x/sys v0.36.0 // indirect
40+
golang.org/x/text v0.29.0 // indirect
3641
)

0 commit comments

Comments
 (0)