Add new storage backend: Dropbox (#103)

This commit is contained in:
MaxJa4
2023-08-20 16:29:35 +02:00
parent 67e7288855
commit 4e04cb9926
5 changed files with 215 additions and 5 deletions

View File

@@ -70,6 +70,8 @@ type Config struct {
AzureStorageContainerName string `split_words:"true"`
AzureStoragePath string `split_words:"true"`
AzureStorageEndpoint string `split_words:"true" default:"https://{{ .AccountName }}.blob.core.windows.net/"`
DropboxToken string `split_words:"true"`
DropboxRemotePath string `split_words:"true"`
}
func (c *Config) resolveSecret(envVar string, secretPath string) (string, error) {

View File

@@ -19,6 +19,7 @@ import (
"github.com/offen/docker-volume-backup/internal/storage"
"github.com/offen/docker-volume-backup/internal/storage/azure"
"github.com/offen/docker-volume-backup/internal/storage/dropbox"
"github.com/offen/docker-volume-backup/internal/storage/local"
"github.com/offen/docker-volume-backup/internal/storage/s3"
"github.com/offen/docker-volume-backup/internal/storage/ssh"
@@ -70,11 +71,12 @@ func newScript() (*script, error) {
StartTime: time.Now(),
LogOutput: logBuffer,
Storages: map[string]StorageStats{
"S3": {},
"WebDAV": {},
"SSH": {},
"Local": {},
"Azure": {},
"S3": {},
"WebDAV": {},
"SSH": {},
"Local": {},
"Azure": {},
"Dropbox": {},
},
},
}
@@ -218,6 +220,18 @@ func newScript() (*script, error) {
s.storages = append(s.storages, azureBackend)
}
if s.c.DropboxToken != "" {
dropboxConfig := dropbox.Config{
Token: s.c.DropboxToken,
RemotePath: s.c.DropboxRemotePath,
}
dropboxBackend, err := dropbox.NewStorageBackend(dropboxConfig, logFunc)
if err != nil {
return nil, err
}
s.storages = append(s.storages, dropboxBackend)
}
if s.c.EmailNotificationRecipient != "" {
emailURL := fmt.Sprintf(
"smtp://%s:%s@%s:%d/?from=%s&to=%s",