-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
39 changed files
with
1,282 additions
and
390 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
name: goreleaser | ||
|
||
on: | ||
push: | ||
tags: | ||
- '*' | ||
|
||
jobs: | ||
goreleaser: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- | ||
name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
- | ||
name: Set up Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.17 | ||
- | ||
name: Run GoReleaser | ||
uses: goreleaser/goreleaser-action@v2 | ||
with: | ||
# either 'goreleaser' (default) or 'goreleaser-pro' | ||
distribution: goreleaser | ||
version: latest | ||
args: release --rm-dist | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
# Your GoReleaser Pro key, if you are using the 'goreleaser-pro' distribution | ||
# GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,10 @@ | |
*.o | ||
*.a | ||
*.so | ||
*.yml | ||
payung-local.yml | ||
!payung-reference.yml | ||
!.github/goreleaser.yml | ||
.DS_Store | ||
payung | ||
/payung | ||
|
||
dist/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# This is an example .goreleaser.yml file with some sensible defaults. | ||
# Make sure to check the documentation at https://goreleaser.com | ||
before: | ||
hooks: | ||
# You may remove this if you don't use go modules. | ||
- go mod tidy | ||
# you may remove this if you don't need go generate | ||
- go generate ./... | ||
builds: | ||
- | ||
main: ./cmd/payung | ||
ldflags: | ||
- -s -w -X github.com/syaiful6/payung/version.Version={{.Version}} -X github.com/syaiful6/payung/version.Revision={{.Commit}} | ||
env: | ||
- CGO_ENABLED=0 | ||
goos: | ||
- linux | ||
- windows | ||
- darwin | ||
archives: | ||
- replacements: | ||
darwin: Darwin | ||
linux: Linux | ||
windows: Windows | ||
386: i386 | ||
amd64: x86_64 | ||
checksum: | ||
name_template: 'checksums.txt' | ||
snapshot: | ||
name_template: "{{ incpatch .Version }}-next" | ||
changelog: | ||
sort: asc | ||
filters: | ||
exclude: | ||
- '^docs:' | ||
- '^test:' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,105 @@ | ||
# Payung | ||
|
||
Payung is a system utility for Linux, Mac OS X and BSD. | ||
Payung is a system utility backup for Linux, Mac OS X and BSD. | ||
|
||
This project has beed forked from (gobackup)[https://github.com/huacnlee/gobackup] since 2020. | ||
This project has beed forked from [gobackup](https://github.com/huacnlee/gobackup) since 2020. | ||
|
||
## Current support status | ||
|
||
### Databases | ||
|
||
- MySQL | ||
- PostgreSQL | ||
- Redis | ||
- MongoDB | ||
|
||
### Compressor | ||
- Gzip | ||
- Brotli | ||
|
||
### Storages | ||
- Local | ||
- FTP | ||
- SCP | ||
- Amazon S3 | ||
- Alibaba Cloud Object Storage Service (OSS) | ||
- Dropbox | ||
|
||
### Notification | ||
- Slack | ||
|
||
## Installation | ||
|
||
Currently we don't provides binary release, you need to compile it from source yourself. | ||
|
||
- Clone this repository: `git clone https://github.com/syaiful6/payung.git` | ||
- Build the binary: `make build` | ||
- Copy the output binary: `payung` to your PATH: `sudo cp payung /usr/local/bin` | ||
|
||
## Configuration | ||
|
||
Payung will seek config files in: | ||
- ~/.payung/payung.yml | ||
- /etc/payung/payung.yml | ||
|
||
Example config file: [payung-reference.yml](https://github.com/syaiful6/payung/blob/develop/payung-reference.yml). | ||
|
||
```yml | ||
models: | ||
gitlab: | ||
compress_with: | ||
type: brotli | ||
level: 8 | ||
store_with: | ||
type: s3 | ||
bucket: backups | ||
region: us-east-1 | ||
access_key_id: xxxxxx | ||
secret_access_key: xxxxxxx | ||
max_retries: 5 | ||
notify_with: | ||
slack: | ||
type: slack | ||
webhook_url: https://hooks.slack.com/services/xxxxx | ||
channel: database_backups | ||
send_on: | ||
- success | ||
- failed | ||
databases: | ||
gitlab: | ||
type: mysql | ||
host: localhost | ||
port: 3306 | ||
database: gitlab | ||
username: root | ||
password: xxxxxx | ||
additional_options: --single-transaction --quick --max_allowed_packet=1G | ||
archive: | ||
includes: | ||
- /home/git/.ssh/ | ||
- /etc/mysql/my.conf | ||
- /etc/logrotate.d/ | ||
excludes: | ||
- /home/ubuntu/.ssh/known_hosts | ||
- /etc/logrotate.d/syslog | ||
``` | ||
## Usage | ||
You can learn available options with `payung --help` and `payung perform --help`. | ||
|
||
For example this is how you provides custom config file and dump path folder. | ||
|
||
``` | ||
payung perform -c ~/backups/payung.yml -d ~/backups/workdir | ||
``` | ||
We recommend you to perform backups using cron, here are an example configuration: | ||
``` | ||
5 0 * * * /usr/local/bin/payung perform -c /home/ubuntu/payung.yml -d /mnt/ebs/backups >> /mnt/ebs/backups/backup.log 2>&1 | ||
``` | ||
### Recommendation | ||
If you use Amazon S3, we recommends to use [AWS S3 object lifecycle](https://docs.aws.amazon.com/AmazonS3/latest/userguide/object-lifecycle-mgmt.html) instead of our storage lifecycle. You can use it to move the object to Glacier or delete the backups if older than one month. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package main | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
"github.com/syaiful6/payung/version" | ||
) | ||
|
||
// show application version number | ||
var showVersion bool | ||
|
||
func main() { | ||
execute() | ||
} | ||
|
||
func execute() error { | ||
// Rootcmd is the rootcommand for | ||
var rootCmd = &cobra.Command{ | ||
Use: "Payung", | ||
Short: "Easy full stack backup operations on UNIX-like systems.", | ||
Long: `Easy full stack backup operations on UNIX-like systems.`, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
if showVersion { | ||
version.PrintVersion() | ||
return | ||
} | ||
cmd.Usage() | ||
}, | ||
} | ||
rootCmd.Flags().BoolVarP(&showVersion, "version", "v", false, "Print payung's current version") | ||
rootCmd.AddCommand(performCmd()) | ||
rootCmd.AddCommand(decompressCommand()) | ||
|
||
return rootCmd.Execute() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package main | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
"github.com/syaiful6/payung/config" | ||
"github.com/syaiful6/payung/model" | ||
) | ||
|
||
func performCmd() *cobra.Command { | ||
var ( | ||
modelName string | ||
configFile string | ||
dumpPath string | ||
) | ||
var performCommand = &cobra.Command{ | ||
Use: "perform", | ||
Short: `Perform backup`, | ||
Long: `Perform backup`, | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
config.Init(configFile, dumpPath) | ||
if len(modelName) == 0 { | ||
performAll() | ||
} else { | ||
performOne(modelName) | ||
} | ||
|
||
return nil | ||
}, | ||
} | ||
performCommand.Flags().StringVarP(&modelName, "model", "m", "", "Model name that you want execute") | ||
performCommand.Flags().StringVarP(&configFile, "config", "c", "", "Special a config file") | ||
performCommand.Flags().StringVarP(&dumpPath, "dumpfile", "d", "", "special Dump path folder") | ||
return performCommand | ||
} | ||
|
||
func performAll() { | ||
for _, modelConfig := range config.Models { | ||
m := model.Model{ | ||
Config: modelConfig, | ||
} | ||
m.Perform() | ||
} | ||
} | ||
|
||
func performOne(modelName string) { | ||
for _, modelConfig := range config.Models { | ||
if modelConfig.Name == modelName { | ||
m := model.Model{ | ||
Config: modelConfig, | ||
} | ||
m.Perform() | ||
return | ||
} | ||
} | ||
} |
Oops, something went wrong.