Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 0.2.1 #106

Merged
merged 58 commits into from
Dec 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
83eff2c
Bump golang.org/x/crypto from 0.26.0 to 0.27.0 in the all group
dependabot[bot] Sep 6, 2024
1c08255
Merge pull request #80 from essentialkaos/dependabot/go_modules/devel…
andyone Sep 6, 2024
6d6159d
Bump github.com/essentialkaos/ek/v13 in the all group
dependabot[bot] Sep 13, 2024
7fa7f65
Merge pull request #81 from essentialkaos/dependabot/go_modules/devel…
andyone Sep 13, 2024
0ebc829
Bump github.com/essentialkaos/ek/v13 in the all group
dependabot[bot] Sep 16, 2024
860c207
Merge pull request #82 from essentialkaos/dependabot/go_modules/devel…
andyone Sep 16, 2024
d59accb
Bump the all group with 2 updates
dependabot[bot] Sep 17, 2024
96591ea
Merge pull request #83 from essentialkaos/dependabot/go_modules/devel…
andyone Sep 17, 2024
bbc972b
Bump the all group with 3 updates
dependabot[bot] Sep 18, 2024
bcb5a12
Merge pull request #84 from essentialkaos/dependabot/go_modules/devel…
andyone Sep 18, 2024
2149c46
Bump the all group across 1 directory with 4 updates
dependabot[bot] Sep 23, 2024
ec5ae08
Merge pull request #86 from essentialkaos/dependabot/go_modules/devel…
andyone Sep 23, 2024
bb0bfe4
Bump the all group with 3 updates
dependabot[bot] Sep 24, 2024
e4a511e
Merge pull request #87 from essentialkaos/dependabot/go_modules/devel…
andyone Sep 24, 2024
cc5578b
Improve Dependabot configuration
andyone Sep 24, 2024
7e863f6
Bump the all group with 3 updates
dependabot[bot] Sep 26, 2024
b756363
Merge pull request #88 from essentialkaos/dependabot/go_modules/devel…
andyone Sep 26, 2024
093d8c0
Bump the all group with 3 updates
dependabot[bot] Sep 30, 2024
fe7dfff
Merge pull request #89 from essentialkaos/dependabot/go_modules/devel…
andyone Oct 1, 2024
57f9dff
Bump the all group across 1 directory with 3 updates
dependabot[bot] Oct 3, 2024
e7ff04e
Merge pull request #91 from essentialkaos/dependabot/go_modules/devel…
andyone Oct 3, 2024
38c8955
Bump the all group with 3 updates
dependabot[bot] Oct 4, 2024
033f23f
Merge pull request #92 from essentialkaos/dependabot/go_modules/devel…
andyone Oct 4, 2024
17f9966
Bump the all group with 5 updates
dependabot[bot] Oct 7, 2024
b2d2851
Merge pull request #93 from essentialkaos/dependabot/go_modules/devel…
andyone Oct 7, 2024
66b5d74
Bump the all group across 1 directory with 5 updates
dependabot[bot] Oct 9, 2024
a60d3b2
Merge pull request #95 from essentialkaos/dependabot/go_modules/devel…
andyone Oct 9, 2024
f6622c8
Regenerate Makefile with the latest version of gomakegen
andyone Oct 11, 2024
d5f4353
Dependencies update
andyone Oct 11, 2024
328030b
Remove codebeat integration
andyone Oct 11, 2024
519ff2a
Bump the all group across 1 directory with 3 updates
dependabot[bot] Oct 17, 2024
2adcdfd
Merge pull request #98 from essentialkaos/dependabot/go_modules/devel…
andyone Oct 17, 2024
5ebbffc
Bump github.com/essentialkaos/ek/v13 in the all group
dependabot[bot] Oct 18, 2024
4718242
Merge pull request #99 from essentialkaos/dependabot/go_modules/devel…
andyone Oct 18, 2024
7cc50e1
Bump the all group with 2 updates
dependabot[bot] Oct 21, 2024
39d51d5
Merge pull request #100 from essentialkaos/dependabot/go_modules/deve…
andyone Oct 21, 2024
6d8a1db
Fix compatibility with the latest version of ek package
andyone Oct 21, 2024
dd34e08
Bump the all group across 1 directory with 7 updates
dependabot[bot] Oct 29, 2024
c0725ad
Merge pull request #104 from essentialkaos/dependabot/go_modules/deve…
andyone Oct 30, 2024
d08cb1b
Bump github.com/essentialkaos/ek/v13 in the all group
dependabot[bot] Nov 1, 2024
470fd01
Merge pull request #105 from essentialkaos/dependabot/go_modules/deve…
andyone Nov 1, 2024
8a6427a
Dependencies update
andyone Dec 4, 2024
19a63a2
Regenerate Makefile with the latest version of gomakegen
andyone Dec 12, 2024
93c5f9a
Dependencies update
andyone Dec 12, 2024
ec26d42
Update card
andyone Dec 14, 2024
4e1e500
Fix possible panic due to empty API response
andyone Dec 18, 2024
9203506
Spec file fixes
andyone Dec 26, 2024
ec86263
Code refactoring
andyone Dec 26, 2024
7de73e7
Migrate to Alpine 3.20
andyone Dec 26, 2024
07cc353
Use default temp dir if not set in configuration
andyone Dec 26, 2024
e133811
Update spec changelog
andyone Dec 26, 2024
8f7e9ec
Improve spec
andyone Dec 26, 2024
9cea145
Code refactoring
andyone Dec 26, 2024
1eb0512
Improve configuration
andyone Dec 26, 2024
af00fe5
Improvements
andyone Dec 27, 2024
42950d0
Dependencies update
andyone Dec 27, 2024
9040e70
Improve timers schedule
andyone Dec 28, 2024
15483df
Update confluence schedule
andyone Dec 28, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions .codebeatsettings

This file was deleted.

6 changes: 3 additions & 3 deletions .docker/alpine.docker
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
## REGISTRY CONFIGURATION ######################################################

ARG REGISTRY="docker.io"
ARG REGISTRY="ghcr.io"

## BUILDER #####################################################################

FROM ${REGISTRY}/essentialkaos/golang:alpine3.18 as builder
FROM ${REGISTRY}/essentialkaos/golang:alpine3.20 as builder

WORKDIR /go/src/github.com/essentialkaos/atlassian-cloud-backuper

Expand All @@ -14,7 +14,7 @@ RUN make deps && make all

## FINAL IMAGE #################################################################

FROM ${REGISTRY}/essentialkaos/alpine:3.18
FROM ${REGISTRY}/essentialkaos/alpine:3.20

LABEL org.opencontainers.image.title="atlassian-cloud-backuper" \
org.opencontainers.image.description="Atlassian Cloud Backuper" \
Expand Down
4 changes: 2 additions & 2 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ updates:
schedule:
interval: "daily"
timezone: "Etc/UTC"
time: "07:00"
time: "03:00"
labels:
- "PR • MAINTENANCE"
assignees:
Expand All @@ -27,7 +27,7 @@ updates:
schedule:
interval: "daily"
timezone: "Etc/UTC"
time: "08:00"
time: "03:00"
labels:
- "PR • MAINTENANCE"
assignees:
Expand Down
2 changes: 1 addition & 1 deletion .github/images/card.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 14 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
################################################################################

# This Makefile generated by GoMakeGen 3.1.0 using next command:
# This Makefile generated by GoMakeGen 3.2.3 using next command:
# gomakegen --mod .
#
# More info: https://kaos.sh/gomakegen
Expand All @@ -15,7 +15,12 @@ ifdef PROXY ## Force proxy usage for downloading dependencies (Flag)
export GOPROXY=https://proxy.golang.org/cached-only,direct
endif

COMPAT ?= 1.19
ifdef CGO ## Enable CGO usage (Flag)
export CGO_ENABLED=1
else
export CGO_ENABLED=0
endif

MAKEDIR = $(dir $(realpath $(firstword $(MAKEFILE_LIST))))
GITREV ?= $(shell test -s $(MAKEDIR)/.git && git rev-parse --short HEAD)

Expand Down Expand Up @@ -49,19 +54,22 @@ update: mod-update ## Update dependencies to the latest versions
vendor: mod-vendor ## Make vendored copy of dependencies

mod-init:
@echo "[1/2] Modules initialization…"
@echo "[1/3] Modules initialization…"
@rm -f go.mod go.sum
ifdef MODULE_PATH ## Module path for initialization (String)
@go mod init $(MODULE_PATH)
else
@go mod init
endif

@echo "[2/2] Dependencies cleanup…"
@echo "[2/3] Dependencies cleanup…"
ifdef COMPAT ## Compatible Go version (String)
@go mod tidy $(VERBOSE_FLAG) -compat=$(COMPAT) -go=$(COMPAT)
else
@go mod tidy $(VERBOSE_FLAG)
endif
@echo "[3/3] Stripping toolchain info…"
@grep -q 'toolchain ' go.mod && go mod edit -toolchain=none || :

mod-update:
@echo "[1/4] Updating dependencies…"
Expand Down Expand Up @@ -111,8 +119,9 @@ help: ## Show this info
@echo -e '\n\033[1mVariables:\033[0m\n'
@grep -E '^ifdef [A-Z_]+ .*?## .*$$' $(abspath $(lastword $(MAKEFILE_LIST))) \
| sed 's/ifdef //' \
| sort -h \
| awk 'BEGIN {FS = " .*?## "}; {printf " \033[32m%-11s\033[0m %s\n", $$1, $$2}'
@echo -e ''
@echo -e '\033[90mGenerated by GoMakeGen 3.1.0\033[0m\n'
@echo -e '\033[90mGenerated by GoMakeGen 3.2.3\033[0m\n'

################################################################################
113 changes: 62 additions & 51 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"os"
"strings"

"github.com/essentialkaos/ek/v13/errutil"
"github.com/essentialkaos/ek/v13/errors"
"github.com/essentialkaos/ek/v13/fmtc"
"github.com/essentialkaos/ek/v13/knf"
"github.com/essentialkaos/ek/v13/log"
Expand Down Expand Up @@ -42,7 +42,7 @@ import (
// Basic utility info
const (
APP = "Atlassian Cloud Backuper"
VER = "0.2.0"
VER = "0.2.1"
DESC = "Tool for backuping Atlassian cloud services (Jira and Confluence)"
)

Expand Down Expand Up @@ -96,7 +96,7 @@ const (
LOG_DIR = "log:dir"
LOG_FILE = "log:file"
LOG_FORMAT = "log:format"
LOG_MODE = "log:perms"
LOG_MODE = "log:mode"
LOG_LEVEL = "log:level"
)

Expand Down Expand Up @@ -147,7 +147,7 @@ func Run(gitRev string, gomod []byte) {

if !errs.IsEmpty() {
terminal.Error("Options parsing errors:")
terminal.Error(errs.String())
terminal.Error(errs.Error(" - "))
os.Exit(1)
}

Expand Down Expand Up @@ -178,7 +178,7 @@ func Run(gitRev string, gomod []byte) {
os.Exit(0)
}

err := errutil.Chain(
err := errors.Chain(
loadConfig,
validateConfig,
setupLogger,
Expand All @@ -192,7 +192,7 @@ func Run(gitRev string, gomod []byte) {
log.Divider()
log.Aux("%s %s starting…", APP, VER)

err = errutil.Chain(
err = errors.Chain(
setupTemp,
setupReq,
)
Expand All @@ -202,6 +202,8 @@ func Run(gitRev string, gomod []byte) {
os.Exit(1)
}

defer temp.Clean()

if options.GetB(OPT_SERVER) {
err = startServer()
} else {
Expand Down Expand Up @@ -300,66 +302,71 @@ func loadConfig() error {

// validateConfig validates configuration file values
func validateConfig() error {
validators := []*knf.Validator{
validators := knf.Validators{
{ACCESS_ACCOUNT, knfv.Set, nil},
{ACCESS_EMAIL, knfv.Set, nil},
{ACCESS_API_KEY, knfv.Set, nil},
{ACCESS_EMAIL, knfn.Mail, nil},
{STORAGE_TYPE, knfv.SetToAnyIgnoreCase, []string{
STORAGE_FS, STORAGE_SFTP, STORAGE_S3,
}},
{TEMP_DIR, knff.Perms, "DWRX"},
{LOG_FORMAT, knfv.SetToAnyIgnoreCase, []string{
"", "text", "json",
}},
{LOG_LEVEL, knfv.SetToAnyIgnoreCase, []string{
"", "debug", "info", "warn", "error", "crit",
}},
{TEMP_DIR, knff.Perms, "DWX"},
{LOG_LEVEL, knfv.SetToAnyIgnoreCase, log.Levels()},
}

switch strings.ToLower(knfu.GetS(STORAGE_TYPE)) {
case STORAGE_FS:
validators = append(validators,
&knf.Validator{STORAGE_FS_PATH, knff.Perms, "DRW"},
)
validators = validators.AddIf(
knfu.GetS(STORAGE_TYPE) == STORAGE_FS,
knf.Validators{
{STORAGE_FS_PATH, knff.Perms, "DRW"},
},
)

case STORAGE_SFTP:
validators = append(validators,
&knf.Validator{STORAGE_SFTP_HOST, knfv.Set, nil},
&knf.Validator{STORAGE_SFTP_USER, knfv.Set, nil},
&knf.Validator{STORAGE_SFTP_KEY, knfv.Set, nil},
&knf.Validator{STORAGE_SFTP_PATH, knfv.Set, nil},
)
validators = validators.AddIf(
knfu.GetS(STORAGE_TYPE) == STORAGE_SFTP,
knf.Validators{
{STORAGE_SFTP_HOST, knfv.Set, nil},
{STORAGE_SFTP_USER, knfv.Set, nil},
{STORAGE_SFTP_KEY, knfv.Set, nil},
{STORAGE_SFTP_PATH, knfv.Set, nil},
},
)

case STORAGE_S3:
validators = append(validators,
&knf.Validator{STORAGE_S3_HOST, knfv.Set, nil},
&knf.Validator{STORAGE_S3_ACCESS_KEY, knfv.Set, nil},
&knf.Validator{STORAGE_S3_SECRET_KEY, knfv.Set, nil},
&knf.Validator{STORAGE_S3_BUCKET, knfv.Set, nil},
&knf.Validator{STORAGE_S3_PART_SIZE, knfv.Greater, 5},
&knf.Validator{STORAGE_S3_PART_SIZE, knfv.Less, 5_000},
)
}
validators = validators.AddIf(
knfu.GetS(STORAGE_TYPE) == STORAGE_S3,
knf.Validators{
{STORAGE_S3_HOST, knfv.Set, nil},
{STORAGE_S3_ACCESS_KEY, knfv.Set, nil},
{STORAGE_S3_SECRET_KEY, knfv.Set, nil},
{STORAGE_S3_BUCKET, knfv.Set, nil},
{STORAGE_S3_PART_SIZE, knfv.TypeSize, nil},
{STORAGE_S3_PART_SIZE, knfv.SizeGreater, 1 * 1024 * 1024},
{STORAGE_S3_PART_SIZE, knfv.SizeLess, 100 * 1024 * 1024},
},
)

if options.GetB(OPT_SERVER) {
validators = append(validators,
&knf.Validator{SERVER_IP, knfn.IP, nil},
&knf.Validator{SERVER_PORT, knfn.Port, nil},
)
}
validators = validators.AddIf(
options.GetB(OPT_SERVER),
knf.Validators{
{SERVER_IP, knfn.IP, nil},
{SERVER_PORT, knfn.Port, nil},
},
)

if knfu.GetS(STORAGE_ENCRYPTION_KEY) != "" {
validators = append(validators,
&knf.Validator{STORAGE_ENCRYPTION_KEY, knfv.LenGreater, 16},
&knf.Validator{STORAGE_ENCRYPTION_KEY, knfv.LenLess, 96},
)
}
validators = validators.AddIf(
knfu.GetS(STORAGE_ENCRYPTION_KEY) != "",
knf.Validators{
{STORAGE_ENCRYPTION_KEY, knfv.LenGreater, 16},
{STORAGE_ENCRYPTION_KEY, knfv.LenLess, 96},
},
)

errs := knfu.Validate(validators)

if len(errs) > 0 {
return errs[0]
if !errs.IsEmpty() {
return errs.First()
}

return nil
Expand All @@ -370,7 +377,7 @@ func setupLogger() error {
var err error

if knfu.GetS(LOG_FILE) != "" {
err = log.Set(knfu.GetS(LOG_FILE), knfu.GetM(LOG_MODE, 0640))
err = log.Set(knfu.GetS(LOG_FILE), knfu.GetM(LOG_MODE, 0644))

if err != nil {
return err
Expand Down Expand Up @@ -403,9 +410,13 @@ func setupLogger() error {
func setupTemp() error {
var err error

temp, err = tmp.NewTemp(knfu.GetS(TEMP_DIR, "/tmp"))
temp, err = tmp.NewTemp(knfu.GetS(TEMP_DIR, os.TempDir()))

return err
if err != nil {
return fmt.Errorf("Can't setup temporary data directory: %w", err)
}

return nil
}

// setupReq configures HTTP request engine
Expand Down Expand Up @@ -530,7 +541,7 @@ func genUsage(section string) *usage.Info {
addUnitedOption(info, STORAGE_S3_SECRET_KEY, "S3 access secret key", "key")
addUnitedOption(info, STORAGE_S3_BUCKET, "S3 bucket", "name")
addUnitedOption(info, STORAGE_S3_PATH, "Path for backups", "path")
addUnitedOption(info, STORAGE_S3_PART_SIZE, "Uploading part size (in MB)", "num")
addUnitedOption(info, STORAGE_S3_PART_SIZE, "Uploading part size", "size")
addUnitedOption(info, JIRA_OUTPUT_FILE, "Jira backup output file name template", "template")
addUnitedOption(info, JIRA_INCLUDE_ATTACHMENTS, "Include attachments to Jira backup", "yes/no")
addUnitedOption(info, JIRA_CLOUD_FORMAT, "Create Jira backup for Cloud", "yes/no")
Expand Down
2 changes: 1 addition & 1 deletion app/basic.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func startApp(args options.Arguments) error {
addEventsHandlers(dispatcher)
}

if knfu.GetS(STORAGE_ENCRYPTION_KEY) != "" {
if knfu.GetS(STORAGE_ENCRYPTION_KEY) != "" && options.GetB(OPT_INTERACTIVE) {
fmtc.NewLine()
terminal.Warn("▲ Backup will be encrypted while uploading. You will not be able to use the")
terminal.Warn(" backup if you lose the encryption key. Keep it in a safe place.")
Expand Down
2 changes: 1 addition & 1 deletion app/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ func getUploader(target string) (uploader.Uploader, error) {
SecretKey: knfu.GetS(STORAGE_S3_SECRET_KEY),
Bucket: knfu.GetS(STORAGE_S3_BUCKET),
Path: path.Join(knfu.GetS(STORAGE_S3_PATH), target),
PartSize: knfu.GetI64(STORAGE_S3_PART_SIZE, 32),
PartSize: knfu.GetSZ(STORAGE_S3_PART_SIZE, 5*1024*1024),
})
}

Expand Down
27 changes: 12 additions & 15 deletions backuper/confluence/confluence-backuper.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,10 +223,9 @@ func (b *ConfluenceBackuper) GetReader(backupFile string) (io.ReadCloser, error)
log.Debug("Downloading file from %s", backupFileURL)

resp, err := req.Request{
URL: backupFileURL,
BasicAuthUsername: b.config.Email,
BasicAuthPassword: b.config.APIKey,
AutoDiscard: true,
URL: backupFileURL,
Auth: req.AuthBasic{b.config.Email, b.config.APIKey},
AutoDiscard: true,
}.Get()

if err != nil {
Expand All @@ -245,11 +244,10 @@ func (b *ConfluenceBackuper) GetReader(backupFile string) (io.ReadCloser, error)
// startBackup starts backup process
func (b *ConfluenceBackuper) startBackup() error {
resp, err := req.Request{
URL: b.config.AccountURL() + "/wiki/rest/obm/1.0/runbackup",
BasicAuthUsername: b.config.Email,
BasicAuthPassword: b.config.APIKey,
Accept: req.CONTENT_TYPE_JSON,
ContentType: req.CONTENT_TYPE_JSON,
URL: b.config.AccountURL() + "/wiki/rest/obm/1.0/runbackup",
Auth: req.AuthBasic{b.config.Email, b.config.APIKey},
Accept: req.CONTENT_TYPE_JSON,
ContentType: req.CONTENT_TYPE_JSON,
Body: &BackupPrefs{
WithAttachments: b.config.WithAttachments,
ForCloud: b.config.ForCloud,
Expand All @@ -270,12 +268,11 @@ func (b *ConfluenceBackuper) startBackup() error {
// getBackupProgress returns backup progress info
func (b *ConfluenceBackuper) getBackupProgress() (*BackupProgressInfo, error) {
resp, err := req.Request{
URL: b.config.AccountURL() + "/wiki/rest/obm/1.0/getprogress",
BasicAuthUsername: b.config.Email,
BasicAuthPassword: b.config.APIKey,
Accept: req.CONTENT_TYPE_JSON,
ContentType: req.CONTENT_TYPE_JSON,
AutoDiscard: true,
URL: b.config.AccountURL() + "/wiki/rest/obm/1.0/getprogress",
Auth: req.AuthBasic{b.config.Email, b.config.APIKey},
Accept: req.CONTENT_TYPE_JSON,
ContentType: req.CONTENT_TYPE_JSON,
AutoDiscard: true,
}.Get()

if err != nil {
Expand Down
Loading
Loading