Skip to content
This repository has been archived by the owner on Nov 3, 2022. It is now read-only.

Fix rclone upload and add config section #110

Merged
merged 3 commits into from
May 4, 2020
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ rclone:
bucket: "my-backup-bucket"
# See https://rclone.org/docs/ for details on how to configure rclone
configFilePath: /etc/rclone.conf
configSection: "myrclonesection"
# SFTP upload (optional)
sftp:
host: sftp.company.com
Expand Down
7 changes: 6 additions & 1 deletion pkg/backup/rclone.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,13 @@ func rcloneUpload(file string, plan config.Plan) (string, error) {

fileName := filepath.Base(file)

configSection := plan.Rclone.ConfigSection
if "" == configSection {
configSection = plan.Name
}

upload := fmt.Sprintf("rclone --config=\"%v\" copy %v %v:%v/%v",
plan.Rclone.ConfigFilePath, plan.Name, plan.Rclone.Bucket, fileName)
plan.Rclone.ConfigFilePath, file, configSection, plan.Rclone.Bucket, fileName)

result, err := sh.Command("/bin/sh", "-c", upload).SetTimeout(time.Duration(plan.Scheduler.Timeout) * time.Minute).CombinedOutput()
output := ""
Expand Down
1 change: 1 addition & 0 deletions pkg/config/plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ type GCloud struct {
type Rclone struct {
Bucket string `yaml:"bucket"`
ConfigFilePath string `yaml:"configFilePath"`
ConfigSection string `yaml:"configSection"`
}

type Azure struct {
Expand Down