Skip to content

Commit

Permalink
Merge pull request #31 from mittwald/task/add-restic-prune
Browse files Browse the repository at this point in the history
add restic prune and up deps
  • Loading branch information
Lucaber authored Jun 16, 2023
2 parents 6359f82 + cc2973c commit e7e7a41
Show file tree
Hide file tree
Showing 34 changed files with 1,095 additions and 623 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Build & Test

on: [push, pull_request]
on: [push]

jobs:

Expand All @@ -10,25 +10,25 @@ jobs:
- uses: actions/checkout@v2

- name: Set up Go
uses: actions/setup-go@v2
uses: actions/setup-go@v4
with:
go-version: 1.15
go-version: "1.20"

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
version: latest
args: release --rm-dist --snapshot --skip-publish -f build/ci/.goreleaser.yml
args: release --clean --snapshot --skip-publish -f build/ci/.goreleaser.yml

test:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2

- name: Set up Go
uses: actions/setup-go@v2
uses: actions/setup-go@v4
with:
go-version: 1.15
go-version: "1.20"

- name: Install restic
run: |
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,13 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.20"

- run: docker login -u "${{ secrets.QUAY_IO_USER }}" -p "${{ secrets.QUAY_IO_TOKEN }}" quay.io

- run: curl -sL https://git.io/goreleaser | bash -s -- --config build/ci/.goreleaser.yml --rm-dist
- run: curl -sL https://git.io/goreleaser | bash -s -- --config build/ci/.goreleaser.yml --clean
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_USER_TOKEN }}
11 changes: 5 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
BINARY_NAME = brudi
COMMIT_HASH = $(shell git rev-parse --verify HEAD)
CURDIR = $(shell pwd)
GOLANGCI_LINT_VER = v1.35.0

.PHONY: build test

Expand Down Expand Up @@ -29,20 +28,20 @@ lintci:
docker run --rm \
-v $(CURDIR):/app \
-w /app \
-e GOLANGCI_ADDITIONAL_YML=/app/build/package/ci/.golangci.yml \
quay.io/mittwald/golangci-lint:0.0.8 \
-e GOLANGCI_ADDITIONAL_YML=/app/build/ci/.golangci.yml \
quay.io/mittwald/golangci-lint:0.0.29 \
golangci-lint run -v --fix ./...

lint:
docker run --rm \
-v $(shell go env GOPATH):/go \
-v ${CURDIR}:/app -w /app \
-e GOLANGCI_ADDITIONAL_YML=/app/build/package/ci/.golangci.yml \
quay.io/mittwald/golangci-lint:0.0.8 \
-e GOLANGCI_ADDITIONAL_YML=/app/build/ci/.golangci.yml \
quay.io/mittwald/golangci-lint:0.0.29 \
golangci-lint run -v --fix ./...

goreleaser:
curl -sL https://git.io/goreleaser | bash -s -- --snapshot --skip-publish --rm-dist
curl -sL https://git.io/goreleaser | bash -s -- --debug --snapshot --skip-publish --clean

upTestMongo: downTestMongo
trap 'cd $(CURDIR) && make downTestMongo' 0 1 2 3 6 9 15
Expand Down
7 changes: 7 additions & 0 deletions build/ci/.golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,10 @@ run:
- test/
timeout: 10m

linters:
disable:
- forcetypeassert

linters-settings:
cyclop:
max-complexity: 15
15 changes: 3 additions & 12 deletions build/ci/.goreleaser.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,19 @@
before:
hooks:
- go mod download
- make lintci
- go mod tidy

builds:
-
env:
- CGO_ENABLED=0
binary: brudi
ldflags:
- -s
- -w
- -X 'github.com/mittwald/brudi/cmd.tag={{ .Tag }}'
- -s -w -X 'github.com/mittwald/brudi/cmd.tag={{ .Version }}'
goos:
- darwin
- linux
goarch:
- amd64
archives:
- replacements:
darwin: Darwin
linux: Linux
windows: Windows
386: i386
amd64: x86_64
checksum:
name_template: 'checksums.txt'
snapshot:
Expand Down
2 changes: 1 addition & 1 deletion build/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM alpine:3.12
FROM alpine:3.18

LABEL maintainer="Mittwald CM Service <https://github.com/mittwald>"

Expand Down
2 changes: 1 addition & 1 deletion cmd/mongodump.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ var (
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

err := source.DoBackupForKind(ctx, mongodump.Kind, cleanup, useRestic, useResticForget)
err := source.DoBackupForKind(ctx, mongodump.Kind, cleanup, useRestic, useResticForget, useResticPrune)
if err != nil {
panic(err)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/mongorestore.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ var (
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

err := source.DoRestoreForKind(ctx, mongorestore.Kind, cleanup, useRestic, useResticForget)
err := source.DoRestoreForKind(ctx, mongorestore.Kind, cleanup, useRestic)
if err != nil {
panic(err)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/mysqldump.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ var (
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

err := source.DoBackupForKind(ctx, mysqldump.Kind, cleanup, useRestic, useResticForget)
err := source.DoBackupForKind(ctx, mysqldump.Kind, cleanup, useRestic, useResticForget, useResticPrune)
if err != nil {
panic(err)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/mysqlrestore.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ var (
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

err := source.DoRestoreForKind(ctx, mysqlrestore.Kind, cleanup, useRestic, useResticForget)
err := source.DoRestoreForKind(ctx, mysqlrestore.Kind, cleanup, useRestic)
if err != nil {
panic(err)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/pgdump.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ var (
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

err := source.DoBackupForKind(ctx, pgdump.Kind, cleanup, useRestic, useResticForget)
err := source.DoBackupForKind(ctx, pgdump.Kind, cleanup, useRestic, useResticForget, useResticPrune)
if err != nil {
panic(err)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/pgrestore.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ var (
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

err := source.DoRestoreForKind(ctx, pgrestore.Kind, cleanup, useRestic, useResticForget)
err := source.DoRestoreForKind(ctx, pgrestore.Kind, cleanup, useRestic)
if err != nil {
panic(err)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/psql.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ var (
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

err := source.DoRestoreForKind(ctx, psql.Kind, cleanup, useRestic, useResticForget)
err := source.DoRestoreForKind(ctx, psql.Kind, cleanup, useRestic)
if err != nil {
panic(err)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/redisdump.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ var (
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

err := source.DoBackupForKind(ctx, redisdump.Kind, cleanup, useRestic, useResticForget)
err := source.DoBackupForKind(ctx, redisdump.Kind, cleanup, useRestic, useResticForget, useResticPrune)
if err != nil {
panic(err)
}
Expand Down
5 changes: 4 additions & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ var (
cfgFiles []string
useRestic bool
useResticForget bool
useResticPrune bool
cleanup bool

rootCmd = &cobra.Command{
Expand All @@ -33,7 +34,9 @@ func init() {
cobra.OnInitialize(initConfig)
rootCmd.PersistentFlags().BoolVar(&useRestic, "restic", false, "backup result with 'restic backup'")

rootCmd.PersistentFlags().BoolVar(&useResticForget, "restic-forget", false, "executes 'restic forget' after backing up things with restic")
rootCmd.PersistentFlags().BoolVar(&useResticForget, "restic-forget", false, "executes 'restic forget' after backing up things with restic (NO PRUNING)")

rootCmd.PersistentFlags().BoolVar(&useResticPrune, "restic-prune", false, "executes 'restic prune'")

rootCmd.PersistentFlags().BoolVar(&cleanup, "cleanup", false, "cleanup backup files afterwards")

Expand Down
2 changes: 1 addition & 1 deletion cmd/tar.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ var (
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

err := source.DoBackupForKind(ctx, tar.Kind, cleanup, useRestic, useResticForget)
err := source.DoBackupForKind(ctx, tar.Kind, cleanup, useRestic, useResticForget, useResticPrune)
if err != nil {
panic(err)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/tarrestore.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ var (
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

err := source.DoRestoreForKind(ctx, tarrestore.Kind, cleanup, useRestic, useResticForget)
err := source.DoRestoreForKind(ctx, tarrestore.Kind, cleanup, useRestic)
if err != nil {
panic(err)
}
Expand Down
98 changes: 76 additions & 22 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,34 +1,88 @@
module github.com/mittwald/brudi

go 1.15
go 1.20

require (
github.com/cockroachdb/apd v1.1.0 // indirect
github.com/docker/go-connections v0.4.0
github.com/fsnotify/fsnotify v1.4.8 // indirect
github.com/go-playground/validator/v10 v10.2.0
github.com/go-playground/validator/v10 v10.14.1
github.com/go-redis/redis v6.15.9+incompatible
github.com/go-sql-driver/mysql v1.5.0
github.com/gofrs/uuid v3.3.0+incompatible // indirect
github.com/google/uuid v1.1.2
github.com/jackc/fake v0.0.0-20150926172116-812a484cc733 // indirect
github.com/go-sql-driver/mysql v1.7.1
github.com/jackc/pgx v3.6.2+incompatible
github.com/lib/pq v1.9.0 // indirect
github.com/mitchellh/go-homedir v1.1.0
github.com/pkg/errors v0.9.1
github.com/shopspring/decimal v1.2.0 // indirect
github.com/sirupsen/logrus v1.4.2
github.com/spf13/afero v1.2.2 // indirect
github.com/spf13/cast v1.3.1 // indirect
github.com/spf13/cobra v0.0.6
github.com/sirupsen/logrus v1.9.3
github.com/spf13/cobra v1.7.0
github.com/spf13/viper v1.16.0
github.com/stretchr/testify v1.8.4
github.com/testcontainers/testcontainers-go v0.20.1
go.mongodb.org/mongo-driver v1.11.7
golang.org/x/term v0.9.0
gotest.tools v2.2.0+incompatible
)

require (
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
github.com/cockroachdb/apd v1.1.0 // indirect
github.com/containerd/containerd v1.7.2 // indirect
github.com/cpuguy83/dockercfg v0.3.1 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/docker/distribution v2.8.2+incompatible // indirect
github.com/docker/docker v24.0.2+incompatible // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.2 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/gofrs/uuid v4.4.0+incompatible // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/imdario/mergo v0.3.16 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jackc/fake v0.0.0-20150926172116-812a484cc733 // indirect
github.com/klauspost/compress v1.16.6 // indirect
github.com/leodido/go-urn v1.2.4 // indirect
github.com/lib/pq v1.10.9 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/moby/patternmatcher v0.5.0 // indirect
github.com/moby/sys/sequential v0.5.0 // indirect
github.com/moby/term v0.5.0 // indirect
github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe // indirect
github.com/morikuni/aec v1.0.0 // indirect
github.com/onsi/ginkgo v1.16.5 // indirect
github.com/onsi/gomega v1.27.8 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.1.0-rc3 // indirect
github.com/opencontainers/runc v1.1.7 // indirect
github.com/pelletier/go-toml/v2 v2.0.8 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/shopspring/decimal v1.3.1 // indirect
github.com/spf13/afero v1.9.5 // indirect
github.com/spf13/cast v1.5.1 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/viper v1.6.2
github.com/stretchr/testify v1.6.1
github.com/testcontainers/testcontainers-go v0.9.0
go.mongodb.org/mongo-driver v1.4.4
golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073
golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527 // indirect
gopkg.in/ini.v1 v1.54.0 // indirect
gotest.tools v0.0.0-20181223230014-1083505acf35
github.com/subosito/gotenv v1.4.2 // indirect
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
github.com/xdg-go/scram v1.1.1 // indirect
github.com/xdg-go/stringprep v1.0.3 // indirect
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d // indirect
golang.org/x/crypto v0.10.0 // indirect
golang.org/x/mod v0.11.0 // indirect
golang.org/x/net v0.11.0 // indirect
golang.org/x/sync v0.3.0 // indirect
golang.org/x/sys v0.9.0 // indirect
golang.org/x/text v0.10.0 // indirect
golang.org/x/tools v0.9.3 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230530153820-e85fd2cbaebc // indirect
google.golang.org/grpc v1.55.0 // indirect
google.golang.org/protobuf v1.30.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
gotest.tools/v3 v3.4.0 // indirect
)
Loading

0 comments on commit e7e7a41

Please sign in to comment.