Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
15 changes: 15 additions & 0 deletions .fleet/run.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"configurations": [
{
"type": "go",
"name": "run cmd",
"mode": "debug",
"environment": {

}, // optional
"dependsOn": [], // optional
"goExecPath": "/usr/local/go/bin/go",
"params": ["run", "cmd/backup/main.go", "--config=config.yaml"],
}
]
}
5 changes: 5 additions & 0 deletions .fleet/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"go.root": "/usr/local/go/",
"go.path": "/Users/user/go/",
"go.modules": "true"
}
14 changes: 14 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "gomod"
directory: "/"
labels:
- dependencies
- go
schedule:
interval: "daily"
54 changes: 54 additions & 0 deletions .github/workflows/codacy-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

# This workflow checks out code, performs a Codacy security scan
# and integrates the results with the
# GitHub Advanced Security code scanning feature. For more information on
# the Codacy security scan action usage and parameters, see
# https://github.com/codacy/codacy-analysis-cli-action.
# For more information on Codacy Analysis CLI in general, see
# https://github.com/codacy/codacy-analysis-cli.

name: Codacy Security Scan

on:
push:
branches: [ master, protected ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ master ]
schedule:
- cron: '30 21 * * 4'

jobs:
codacy-security-scan:
name: Codacy Security Scan
runs-on: ubuntu-latest
steps:
# Checkout the repository to the GitHub Actions runner
- name: Checkout code
uses: actions/checkout@v2

# Execute Codacy Analysis CLI and generate a SARIF output with the security issues identified during the analysis
- name: Run Codacy Analysis CLI
uses: codacy/codacy-analysis-cli-action@d840f886c4bd4edc059706d09c6a1586111c540b
with:
# Check https://github.com/codacy/codacy-analysis-cli#project-token to get your project token from your Codacy repository
# You can also omit the token and run the tools that support default configurations
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
verbose: true
output: results.sarif
format: sarif
# Adjust severity of non-security issues
gh-code-scanning-compat: true
# Force 0 exit code to allow SARIF file generation
# This will handover control about PR rejection to the GitHub side
max-allowed-issues: 2147483647

# Upload the SARIF file generated in the previous step
- name: Upload SARIF results file
uses: github/codeql-action/upload-sarif@v1
with:
sarif_file: results.sarif
70 changes: 70 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"

on:
push:
branches: [ master, protected ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ master ]
schedule:
- cron: '23 8 * * 6'

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'go' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Learn more about CodeQL language support at https://git.io/codeql-language-support

steps:
- name: Checkout repository
uses: actions/checkout@v2

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
2 changes: 1 addition & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
go-version: 1.18

- name: Build
run: go build -v ./...
run: go build -o backup cmd/backup/main.go

- name: Test
run: go test -v ./...
38 changes: 38 additions & 0 deletions .github/workflows/goreleareser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: goreleaser

on:
push:
tags:
- '*'

permissions:
contents: write
# packages: write
# issues: write

jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
-
name: Fetch all tags
run: git fetch --force --tags
-
name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.18
-
name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
distribution: goreleaser
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GORELEASER_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*.dll
*.so
*.dylib
.idea

# Test binary, built with `go test -c`
*.test
Expand Down
59 changes: 59 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
builds:
- env:
- CGO_ENABLED=0
goos:
- linux
- darwin
goarch:
- amd64
- arm64
main: ./cmd/backup
archives:
- replacements:
darwin: Darwin
linux: Linux
nfpms:
-
id: backup
package_name: backup
vendor: Max Maximov
maintainer: Max Maximov
formats:
- rpm
- deb
- apk
bindir: /usr/bin
version_metadata: git
license: MIT
replacements:
amd64: 64-bit
darwin: macOS
overrides:
rpm:
replacements:
amd64: x86_64
file_name_template: "{{ .ProjectName }}-v{{ .Version }}-{{ .Arch }}"
deb:
replacements:
amd64: x86_64
file_name_template: "{{ .ProjectName }}-v{{ .Version }}-{{ .Arch }}"
apk:
replacements:
amd64: x86_64
file_name_template: "{{ .ProjectName }}-v{{ .Version }}-{{ .Arch }}"
contents:
- src: config_example.yaml
dst: /etc/backup/config.yaml
type: "config|noreplace"
checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ incpatch .Version }}-next"
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'


34 changes: 33 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,33 @@
# backup
# backup
Tool for creation backups.

## usage
* create `.backup.yaml` at user`s home dir with next content
```yaml
#drivers section, describes possible storages of backup`s archives
drivers:
s3: # s3 like storages configurations
default: # name of configuration
access_key: <access_key_id>
secret_key: <secret_key>
bucket: <bucket_name>
url: <endpoint_url>
region: <region>
path: <path_on_bucket>
dir: # just store archives in a directory
default:
output_path: new/dir
```
* build backup
```shell
go build -o backup cmd/backup/main.go
```
* run with args: dir, driver, archive type
```shell
# path started from ~ or . will be resolved to absolute
# s3 - driver name, in example this is eq s3.default
# you can describe many driver configurations
# and use it in args in following format: <driver_type>.<driver_name>
# archive type is optional, one of zip,tar,tgz, first is default
./backup ~/my/dir s3 tgz --config=my_cfg.yaml
```
12 changes: 12 additions & 0 deletions cfg.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
drivers:
s3:
default:
access_key: jwCukHoJg4429WiJxoyKhS
secret_key: ggruvZbAR3qXdrXt7JUB8UnUHCQ1z9xHDMTjB3KaVtf7
bucket: test-backup
url: https://hb.bizmrg.com
region: ru-msk
path: /my/backup
dir:
default:
output_path: new/dir
15 changes: 15 additions & 0 deletions cmd/backup/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package main

import (
"backup/internal/backup"
"context"
"github.com/sirupsen/logrus"
)

func main() {
ctx := context.Background()
err := backup.Run(ctx)
if err != nil {
logrus.Error(err)
}
}
12 changes: 12 additions & 0 deletions config_example.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
drivers:
s3:
default:
access_key: <access_key_id>
secret_key: <secret_key>
bucket: <bucket_name>
url: <endpoint_url>
region: <region>
path: <path_on_bucket>
dir:
default:
output_path: /tmp/backup
Loading