mirror of
https://github.com/offen/docker-volume-backup.git
synced 2025-12-05 17:18:02 +01:00
Compare commits
18 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a01fc3df3f | ||
|
|
37f9bd9a8f | ||
|
|
fb4663b087 | ||
|
|
0fe983dfcc | ||
|
|
5c8bc107de | ||
|
|
9a1e885138 | ||
|
|
241b5d2f25 | ||
|
|
aab47509d9 | ||
|
|
9b52c1f63e | ||
|
|
164d6df3b4 | ||
|
|
4c74313222 | ||
|
|
de03d4f704 | ||
|
|
65626dd3d4 | ||
|
|
69eceb3982 | ||
|
|
1d45062100 | ||
|
|
64d934102d | ||
|
|
0f224e4fb8 | ||
|
|
6029225f74 |
3
.github/workflows/deploy-docs.yml
vendored
3
.github/workflows/deploy-docs.yml
vendored
@@ -3,6 +3,9 @@ name: Deploy Documenation site to GitHub Pages
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: ['main']
|
branches: ['main']
|
||||||
|
paths:
|
||||||
|
- 'docs/**'
|
||||||
|
- '.github/workflows/deploy-docs.yml'
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
|
|||||||
39
.github/workflows/release.yml
vendored
39
.github/workflows/release.yml
vendored
@@ -15,6 +15,38 @@ jobs:
|
|||||||
- name: Check out the repo
|
- name: Check out the repo
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: set Environment Variables
|
||||||
|
id: env
|
||||||
|
run: |
|
||||||
|
echo "NOW=$(date +'%F %Z %T')" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Docker meta
|
||||||
|
id: meta
|
||||||
|
uses: docker/metadata-action@v5
|
||||||
|
with:
|
||||||
|
# list of Docker images to use as base name for tags
|
||||||
|
images: |
|
||||||
|
offen/docker-volume-backup
|
||||||
|
ghcr.io/offen/docker-volume-backup
|
||||||
|
# define global behaviour for tags
|
||||||
|
flavor: |
|
||||||
|
latest=false
|
||||||
|
# specify one tag which never gets set, to prevent the tag-attribute being empty, as it will fallback to a default
|
||||||
|
tags: |
|
||||||
|
# output v2.42.1-alpha.1 (incl. pre-releases)
|
||||||
|
type=semver,pattern=v{{version}},enable=false
|
||||||
|
labels: |
|
||||||
|
org.opencontainers.image.title=${{github.event.repository.name}}
|
||||||
|
org.opencontainers.image.description="Backup Docker volumes locally or to any S3, WebDAV, Azure Blob Storage, Dropbox or SSH compatible storage"
|
||||||
|
org.opencontainers.image.vendor=${{github.repository_owner}}
|
||||||
|
org.opencontainers.image.licenses="MPL-2.0"
|
||||||
|
org.opencontainers.image.version=${{github.ref_name}}
|
||||||
|
org.opencontainers.image.created=${{ env.NOW }}
|
||||||
|
org.opencontainers.image.source=${{github.server_url}}/${{github.repository}}
|
||||||
|
org.opencontainers.image.revision=${{github.sha}}
|
||||||
|
org.opencontainers.image.url="https://offen.github.io/docker-volume-backup/"
|
||||||
|
org.opencontainers.image.documentation="https://offen.github.io/docker-volume-backup/"
|
||||||
|
|
||||||
- name: Set up QEMU
|
- name: Set up QEMU
|
||||||
uses: docker/setup-qemu-action@v2
|
uses: docker/setup-qemu-action@v2
|
||||||
|
|
||||||
@@ -35,7 +67,7 @@ jobs:
|
|||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
- name: Extract Docker tags
|
- name: Extract Docker tags
|
||||||
id: meta
|
id: tags
|
||||||
run: |
|
run: |
|
||||||
version_tag="${{github.ref_name}}"
|
version_tag="${{github.ref_name}}"
|
||||||
tags=($version_tag)
|
tags=($version_tag)
|
||||||
@@ -51,9 +83,10 @@ jobs:
|
|||||||
echo "releases=$releases" >> "$GITHUB_OUTPUT"
|
echo "releases=$releases" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
- name: Build and push Docker images
|
- name: Build and push Docker images
|
||||||
uses: docker/build-push-action@v4
|
uses: docker/build-push-action@v5
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
push: true
|
push: true
|
||||||
platforms: linux/amd64,linux/arm64,linux/arm/v7
|
platforms: linux/amd64,linux/arm64,linux/arm/v7
|
||||||
tags: ${{ steps.meta.outputs.releases }}
|
tags: ${{ steps.tags.outputs.releases }}
|
||||||
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
|||||||
@@ -16,6 +16,5 @@ WORKDIR /root
|
|||||||
RUN apk add --no-cache ca-certificates
|
RUN apk add --no-cache ca-certificates
|
||||||
|
|
||||||
COPY --from=builder /app/cmd/backup/backup /usr/bin/backup
|
COPY --from=builder /app/cmd/backup/backup /usr/bin/backup
|
||||||
COPY --chmod=755 ./entrypoint.sh /root/
|
|
||||||
|
|
||||||
ENTRYPOINT ["/root/entrypoint.sh"]
|
ENTRYPOINT ["/usr/bin/backup", "-foreground"]
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ type Config struct {
|
|||||||
BackupFilenameExpand bool `split_words:"true"`
|
BackupFilenameExpand bool `split_words:"true"`
|
||||||
BackupLatestSymlink string `split_words:"true"`
|
BackupLatestSymlink string `split_words:"true"`
|
||||||
BackupArchive string `split_words:"true" default:"/archive"`
|
BackupArchive string `split_words:"true" default:"/archive"`
|
||||||
|
BackupCronExpression string `split_words:"true" default:"@daily"`
|
||||||
BackupRetentionDays int32 `split_words:"true" default:"-1"`
|
BackupRetentionDays int32 `split_words:"true" default:"-1"`
|
||||||
BackupPruningLeeway time.Duration `split_words:"true" default:"1m"`
|
BackupPruningLeeway time.Duration `split_words:"true" default:"1m"`
|
||||||
BackupPruningPrefix string `split_words:"true"`
|
BackupPruningPrefix string `split_words:"true"`
|
||||||
|
|||||||
95
cmd/backup/config_provider.go
Normal file
95
cmd/backup/config_provider.go
Normal file
@@ -0,0 +1,95 @@
|
|||||||
|
// Copyright 2021-2022 - Offen Authors <hioffen@posteo.de>
|
||||||
|
// SPDX-License-Identifier: MPL-2.0
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
|
||||||
|
"github.com/joho/godotenv"
|
||||||
|
"github.com/offen/envconfig"
|
||||||
|
)
|
||||||
|
|
||||||
|
// envProxy is a function that mimics os.LookupEnv but can read values from any other source
|
||||||
|
type envProxy func(string) (string, bool)
|
||||||
|
|
||||||
|
func loadConfig(lookup envProxy) (*Config, error) {
|
||||||
|
envconfig.Lookup = func(key string) (string, bool) {
|
||||||
|
value, okValue := lookup(key)
|
||||||
|
location, okFile := lookup(key + "_FILE")
|
||||||
|
|
||||||
|
switch {
|
||||||
|
case okValue && !okFile: // only value
|
||||||
|
return value, true
|
||||||
|
case !okValue && okFile: // only file
|
||||||
|
contents, err := os.ReadFile(location)
|
||||||
|
if err != nil {
|
||||||
|
return "", false
|
||||||
|
}
|
||||||
|
return string(contents), true
|
||||||
|
case okValue && okFile: // both
|
||||||
|
return "", false
|
||||||
|
default: // neither, ignore
|
||||||
|
return "", false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var c = &Config{}
|
||||||
|
if err := envconfig.Process("", c); err != nil {
|
||||||
|
return nil, fmt.Errorf("loadConfig: failed to process configuration values: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return c, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func loadEnvVars() (*Config, error) {
|
||||||
|
return loadConfig(os.LookupEnv)
|
||||||
|
}
|
||||||
|
|
||||||
|
type configFile struct {
|
||||||
|
name string
|
||||||
|
config *Config
|
||||||
|
additionalEnvVars map[string]string
|
||||||
|
}
|
||||||
|
|
||||||
|
func loadEnvFiles(directory string) ([]configFile, error) {
|
||||||
|
items, err := os.ReadDir(directory)
|
||||||
|
if err != nil {
|
||||||
|
if os.IsNotExist(err) {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return nil, fmt.Errorf("loadEnvFiles: failed to read files from env directory: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
cs := []configFile{}
|
||||||
|
for _, item := range items {
|
||||||
|
if item.IsDir() {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
p := filepath.Join(directory, item.Name())
|
||||||
|
f, err := os.ReadFile(p)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("loadEnvFiles: error reading %s: %w", item.Name(), err)
|
||||||
|
}
|
||||||
|
envFile, err := godotenv.Unmarshal(os.ExpandEnv(string(f)))
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("loadEnvFiles: error reading config file %s: %w", p, err)
|
||||||
|
}
|
||||||
|
lookup := func(key string) (string, bool) {
|
||||||
|
val, ok := envFile[key]
|
||||||
|
if ok {
|
||||||
|
return val, ok
|
||||||
|
}
|
||||||
|
return os.LookupEnv(key)
|
||||||
|
}
|
||||||
|
c, err := loadConfig(lookup)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("loadEnvFiles: error loading config from file %s: %w", p, err)
|
||||||
|
}
|
||||||
|
cs = append(cs, configFile{config: c, name: item.Name(), additionalEnvVars: envFile})
|
||||||
|
}
|
||||||
|
|
||||||
|
return cs, nil
|
||||||
|
}
|
||||||
29
cmd/backup/cron.go
Normal file
29
cmd/backup/cron.go
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
// Copyright 2024 - Offen Authors <hioffen@posteo.de>
|
||||||
|
// SPDX-License-Identifier: MPL-2.0
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/robfig/cron/v3"
|
||||||
|
)
|
||||||
|
|
||||||
|
// checkCronSchedule detects whether the given cron expression will actually
|
||||||
|
// ever be executed or not.
|
||||||
|
func checkCronSchedule(expression string) (ok bool) {
|
||||||
|
defer func() {
|
||||||
|
if err := recover(); err != nil {
|
||||||
|
ok = false
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
sched, err := cron.ParseStandard(expression)
|
||||||
|
if err != nil {
|
||||||
|
ok = false
|
||||||
|
return
|
||||||
|
}
|
||||||
|
now := time.Now()
|
||||||
|
sched.Next(now) // panics when the cron would never run
|
||||||
|
ok = true
|
||||||
|
return
|
||||||
|
}
|
||||||
@@ -188,13 +188,18 @@ func (s *script) withLabeledCommands(step lifecyclePhase, cb func() error) func(
|
|||||||
if s.cli == nil {
|
if s.cli == nil {
|
||||||
return cb
|
return cb
|
||||||
}
|
}
|
||||||
return func() error {
|
return func() (err error) {
|
||||||
if err := s.runLabeledCommands(fmt.Sprintf("docker-volume-backup.%s-pre", step)); err != nil {
|
if err = s.runLabeledCommands(fmt.Sprintf("docker-volume-backup.%s-pre", step)); err != nil {
|
||||||
return fmt.Errorf("withLabeledCommands: %s: error running pre commands: %w", step, err)
|
err = fmt.Errorf("withLabeledCommands: %s: error running pre commands: %w", step, err)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
defer func() {
|
defer func() {
|
||||||
s.must(s.runLabeledCommands(fmt.Sprintf("docker-volume-backup.%s-post", step)))
|
derr := s.runLabeledCommands(fmt.Sprintf("docker-volume-backup.%s-post", step))
|
||||||
|
if err == nil && derr != nil {
|
||||||
|
err = derr
|
||||||
|
}
|
||||||
}()
|
}()
|
||||||
return cb()
|
err = cb()
|
||||||
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,65 +4,240 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"log/slog"
|
||||||
"os"
|
"os"
|
||||||
|
"os/signal"
|
||||||
|
"runtime"
|
||||||
|
"syscall"
|
||||||
|
|
||||||
|
"github.com/robfig/cron/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
type command struct {
|
||||||
s, err := newScript()
|
logger *slog.Logger
|
||||||
if err != nil {
|
}
|
||||||
panic(err)
|
|
||||||
|
func newCommand() *command {
|
||||||
|
return &command{
|
||||||
|
logger: slog.New(slog.NewTextHandler(os.Stdout, nil)),
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
unlock, err := s.lock("/var/lock/dockervolumebackup.lock")
|
func (c *command) must(err error) {
|
||||||
defer func() {
|
if err != nil {
|
||||||
s.must(unlock())
|
c.logger.Error(
|
||||||
}()
|
fmt.Sprintf("Fatal error running command: %v", err),
|
||||||
s.must(err)
|
"error",
|
||||||
|
err,
|
||||||
|
)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func runScript(c *Config, envVars map[string]string) (err error) {
|
||||||
defer func() {
|
defer func() {
|
||||||
if pArg := recover(); pArg != nil {
|
if derr := recover(); derr != nil {
|
||||||
if err, ok := pArg.(error); ok {
|
err = fmt.Errorf("runScript: unexpected panic running script: %v", err)
|
||||||
s.logger.Error(
|
|
||||||
fmt.Sprintf("Executing the script encountered a panic: %v", err),
|
|
||||||
)
|
|
||||||
if hookErr := s.runHooks(err); hookErr != nil {
|
|
||||||
s.logger.Error(
|
|
||||||
fmt.Sprintf("An error occurred calling the registered hooks: %s", hookErr),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
|
||||||
panic(pArg)
|
|
||||||
}
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
if err := s.runHooks(nil); err != nil {
|
s, unlock, err := newScript(c, envVars)
|
||||||
s.logger.Error(
|
if err != nil {
|
||||||
|
err = fmt.Errorf("runScript: error instantiating script: %w", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
defer func() {
|
||||||
|
derr := unlock()
|
||||||
|
if err != nil {
|
||||||
|
err = fmt.Errorf("runScript: error releasing file lock: %w", derr)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
runErr := func() (err error) {
|
||||||
|
scriptErr := func() error {
|
||||||
|
if err := s.withLabeledCommands(lifecyclePhaseArchive, func() (err error) {
|
||||||
|
restartContainersAndServices, err := s.stopContainersAndServices()
|
||||||
|
// The mechanism for restarting containers is not using hooks as it
|
||||||
|
// should happen as soon as possible (i.e. before uploading backups or
|
||||||
|
// similar).
|
||||||
|
defer func() {
|
||||||
|
derr := restartContainersAndServices()
|
||||||
|
if err == nil {
|
||||||
|
err = derr
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
err = s.createArchive()
|
||||||
|
return
|
||||||
|
})(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := s.withLabeledCommands(lifecyclePhaseProcess, s.encryptArchive)(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := s.withLabeledCommands(lifecyclePhaseCopy, s.copyArchive)(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := s.withLabeledCommands(lifecyclePhasePrune, s.pruneBackups)(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}()
|
||||||
|
|
||||||
|
if hookErr := s.runHooks(scriptErr); hookErr != nil {
|
||||||
|
if scriptErr != nil {
|
||||||
|
return fmt.Errorf(
|
||||||
|
"runScript: error %w executing the script followed by %w calling the registered hooks",
|
||||||
|
scriptErr,
|
||||||
|
hookErr,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
return fmt.Errorf(
|
||||||
|
"runScript: the script ran successfully, but an error occurred calling the registered hooks: %w",
|
||||||
|
hookErr,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
if scriptErr != nil {
|
||||||
|
return fmt.Errorf("runScript: error running script: %w", scriptErr)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}()
|
||||||
|
|
||||||
|
if runErr != nil {
|
||||||
|
s.logger.Error(
|
||||||
|
fmt.Sprintf("Script run failed: %v", runErr), "error", runErr,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
return runErr
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *command) runInForeground(profileCronExpression string) error {
|
||||||
|
cr := cron.New(
|
||||||
|
cron.WithParser(
|
||||||
|
cron.NewParser(
|
||||||
|
cron.SecondOptional | cron.Minute | cron.Hour | cron.Dom | cron.Month | cron.Dow | cron.Descriptor,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
addJob := func(config *Config, name string, envVars map[string]string) error {
|
||||||
|
if _, err := cr.AddFunc(config.BackupCronExpression, func() {
|
||||||
|
c.logger.Info(
|
||||||
fmt.Sprintf(
|
fmt.Sprintf(
|
||||||
"Backup procedure ran successfully, but an error ocurred calling the registered hooks: %v",
|
"Now running script on schedule %s",
|
||||||
err,
|
config.BackupCronExpression,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
os.Exit(1)
|
|
||||||
}
|
|
||||||
s.logger.Info("Finished running backup tasks.")
|
|
||||||
}()
|
|
||||||
|
|
||||||
s.must(s.withLabeledCommands(lifecyclePhaseArchive, func() error {
|
if err := runScript(config, envVars); err != nil {
|
||||||
restartContainersAndServices, err := s.stopContainersAndServices()
|
c.logger.Error(
|
||||||
// The mechanism for restarting containers is not using hooks as it
|
fmt.Sprintf(
|
||||||
// should happen as soon as possible (i.e. before uploading backups or
|
"Unexpected error running schedule %s: %v",
|
||||||
// similar).
|
config.BackupCronExpression,
|
||||||
defer func() {
|
err,
|
||||||
s.must(restartContainersAndServices())
|
),
|
||||||
}()
|
"error",
|
||||||
|
err,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}); err != nil {
|
||||||
|
return fmt.Errorf("addJob: error adding schedule %s: %w", config.BackupCronExpression, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
c.logger.Info(fmt.Sprintf("Successfully scheduled backup %s with expression %s", name, config.BackupCronExpression))
|
||||||
|
if ok := checkCronSchedule(config.BackupCronExpression); !ok {
|
||||||
|
c.logger.Warn(
|
||||||
|
fmt.Sprintf("Scheduled cron expression %s will never run, is this intentional?", config.BackupCronExpression),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
cs, err := loadEnvFiles("/etc/dockervolumebackup/conf.d")
|
||||||
|
if err != nil {
|
||||||
|
if !os.IsNotExist(err) {
|
||||||
|
return fmt.Errorf("runInForeground: could not load config from environment files: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
c, err := loadEnvVars()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return fmt.Errorf("runInForeground: could not load config from environment variables: %w", err)
|
||||||
|
} else {
|
||||||
|
err = addJob(c, "from environment", nil)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("runInForeground: error adding job from env: %w", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return s.createArchive()
|
} else {
|
||||||
})())
|
c.logger.Info("/etc/dockervolumebackup/conf.d was found, using configuration files from this directory.")
|
||||||
|
for _, config := range cs {
|
||||||
|
err = addJob(config.config, config.name, config.additionalEnvVars)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("runInForeground: error adding jobs from conf files: %w", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
s.must(s.withLabeledCommands(lifecyclePhaseProcess, s.encryptArchive)())
|
if profileCronExpression != "" {
|
||||||
s.must(s.withLabeledCommands(lifecyclePhaseCopy, s.copyArchive)())
|
if _, err := cr.AddFunc(profileCronExpression, func() {
|
||||||
s.must(s.withLabeledCommands(lifecyclePhasePrune, s.pruneBackups)())
|
memStats := runtime.MemStats{}
|
||||||
|
runtime.ReadMemStats(&memStats)
|
||||||
|
c.logger.Info(
|
||||||
|
"Collecting runtime information",
|
||||||
|
"num_goroutines",
|
||||||
|
runtime.NumGoroutine(),
|
||||||
|
"memory_heap_alloc",
|
||||||
|
formatBytes(memStats.HeapAlloc, false),
|
||||||
|
"memory_heap_inuse",
|
||||||
|
formatBytes(memStats.HeapInuse, false),
|
||||||
|
"memory_heap_sys",
|
||||||
|
formatBytes(memStats.HeapSys, false),
|
||||||
|
"memory_heap_objects",
|
||||||
|
memStats.HeapObjects,
|
||||||
|
)
|
||||||
|
}); err != nil {
|
||||||
|
return fmt.Errorf("runInForeground: error adding profiling job: %w", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var quit = make(chan os.Signal, 1)
|
||||||
|
signal.Notify(quit, syscall.SIGTERM, syscall.SIGINT)
|
||||||
|
cr.Start()
|
||||||
|
<-quit
|
||||||
|
ctx := cr.Stop()
|
||||||
|
<-ctx.Done()
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *command) runAsCommand() error {
|
||||||
|
config, err := loadEnvVars()
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("runAsCommand: error loading env vars: %w", err)
|
||||||
|
}
|
||||||
|
err = runScript(config, nil)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("runAsCommand: error running script: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
foreground := flag.Bool("foreground", false, "run the tool in the foreground")
|
||||||
|
profile := flag.String("profile", "", "collect runtime metrics and log them periodically on the given cron expression")
|
||||||
|
flag.Parse()
|
||||||
|
|
||||||
|
c := newCommand()
|
||||||
|
if *foreground {
|
||||||
|
c.must(c.runInForeground(*profile))
|
||||||
|
} else {
|
||||||
|
c.must(c.runAsCommand())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ import (
|
|||||||
"github.com/containrrr/shoutrrr/pkg/router"
|
"github.com/containrrr/shoutrrr/pkg/router"
|
||||||
"github.com/docker/docker/client"
|
"github.com/docker/docker/client"
|
||||||
"github.com/leekchan/timeutil"
|
"github.com/leekchan/timeutil"
|
||||||
"github.com/offen/envconfig"
|
|
||||||
"github.com/otiai10/copy"
|
"github.com/otiai10/copy"
|
||||||
"golang.org/x/sync/errgroup"
|
"golang.org/x/sync/errgroup"
|
||||||
)
|
)
|
||||||
@@ -58,10 +57,10 @@ type script struct {
|
|||||||
// remote resources like the Docker engine or remote storage locations. All
|
// remote resources like the Docker engine or remote storage locations. All
|
||||||
// reading from env vars or other configuration sources is expected to happen
|
// reading from env vars or other configuration sources is expected to happen
|
||||||
// in this method.
|
// in this method.
|
||||||
func newScript() (*script, error) {
|
func newScript(c *Config, envVars map[string]string) (*script, func() error, error) {
|
||||||
stdOut, logBuffer := buffer(os.Stdout)
|
stdOut, logBuffer := buffer(os.Stdout)
|
||||||
s := &script{
|
s := &script{
|
||||||
c: &Config{},
|
c: c,
|
||||||
logger: slog.New(slog.NewTextHandler(stdOut, nil)),
|
logger: slog.New(slog.NewTextHandler(stdOut, nil)),
|
||||||
stats: &Stats{
|
stats: &Stats{
|
||||||
StartTime: time.Now(),
|
StartTime: time.Now(),
|
||||||
@@ -77,50 +76,47 @@ func newScript() (*script, error) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unlock, err := s.lock("/var/lock/dockervolumebackup.lock")
|
||||||
|
if err != nil {
|
||||||
|
return nil, noop, fmt.Errorf("runScript: error acquiring file lock: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
for key, value := range envVars {
|
||||||
|
currentVal, currentOk := os.LookupEnv(key)
|
||||||
|
defer func(currentKey, currentVal string, currentOk bool) {
|
||||||
|
if !currentOk {
|
||||||
|
_ = os.Unsetenv(currentKey)
|
||||||
|
} else {
|
||||||
|
_ = os.Setenv(currentKey, currentVal)
|
||||||
|
}
|
||||||
|
}(key, currentVal, currentOk)
|
||||||
|
|
||||||
|
if err := os.Setenv(key, value); err != nil {
|
||||||
|
return nil, unlock, fmt.Errorf(
|
||||||
|
"Unexpected error overloading environment %s: %w",
|
||||||
|
s.c.BackupCronExpression,
|
||||||
|
err,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
s.registerHook(hookLevelPlumbing, func(error) error {
|
s.registerHook(hookLevelPlumbing, func(error) error {
|
||||||
s.stats.EndTime = time.Now()
|
s.stats.EndTime = time.Now()
|
||||||
s.stats.TookTime = s.stats.EndTime.Sub(s.stats.StartTime)
|
s.stats.TookTime = s.stats.EndTime.Sub(s.stats.StartTime)
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
|
||||||
envconfig.Lookup = func(key string) (string, bool) {
|
|
||||||
value, okValue := os.LookupEnv(key)
|
|
||||||
location, okFile := os.LookupEnv(key + "_FILE")
|
|
||||||
|
|
||||||
switch {
|
|
||||||
case okValue && !okFile: // only value
|
|
||||||
return value, true
|
|
||||||
case !okValue && okFile: // only file
|
|
||||||
contents, err := os.ReadFile(location)
|
|
||||||
if err != nil {
|
|
||||||
s.must(fmt.Errorf("newScript: failed to read %s! Error: %s", location, err))
|
|
||||||
return "", false
|
|
||||||
}
|
|
||||||
return string(contents), true
|
|
||||||
case okValue && okFile: // both
|
|
||||||
s.must(fmt.Errorf("newScript: both %s and %s are set!", key, key+"_FILE"))
|
|
||||||
return "", false
|
|
||||||
default: // neither, ignore
|
|
||||||
return "", false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := envconfig.Process("", s.c); err != nil {
|
|
||||||
return nil, fmt.Errorf("newScript: failed to process configuration values: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
s.file = path.Join("/tmp", s.c.BackupFilename)
|
s.file = path.Join("/tmp", s.c.BackupFilename)
|
||||||
|
|
||||||
tmplFileName, tErr := template.New("extension").Parse(s.file)
|
tmplFileName, tErr := template.New("extension").Parse(s.file)
|
||||||
if tErr != nil {
|
if tErr != nil {
|
||||||
return nil, fmt.Errorf("newScript: unable to parse backup file extension template: %w", tErr)
|
return nil, unlock, fmt.Errorf("newScript: unable to parse backup file extension template: %w", tErr)
|
||||||
}
|
}
|
||||||
|
|
||||||
var bf bytes.Buffer
|
var bf bytes.Buffer
|
||||||
if tErr := tmplFileName.Execute(&bf, map[string]string{
|
if tErr := tmplFileName.Execute(&bf, map[string]string{
|
||||||
"Extension": fmt.Sprintf("tar.%s", s.c.BackupCompression),
|
"Extension": fmt.Sprintf("tar.%s", s.c.BackupCompression),
|
||||||
}); tErr != nil {
|
}); tErr != nil {
|
||||||
return nil, fmt.Errorf("newScript: error executing backup file extension template: %w", tErr)
|
return nil, unlock, fmt.Errorf("newScript: error executing backup file extension template: %w", tErr)
|
||||||
}
|
}
|
||||||
s.file = bf.String()
|
s.file = bf.String()
|
||||||
|
|
||||||
@@ -131,14 +127,20 @@ func newScript() (*script, error) {
|
|||||||
}
|
}
|
||||||
s.file = timeutil.Strftime(&s.stats.StartTime, s.file)
|
s.file = timeutil.Strftime(&s.stats.StartTime, s.file)
|
||||||
|
|
||||||
_, err := os.Stat("/var/run/docker.sock")
|
_, err = os.Stat("/var/run/docker.sock")
|
||||||
_, dockerHostSet := os.LookupEnv("DOCKER_HOST")
|
_, dockerHostSet := os.LookupEnv("DOCKER_HOST")
|
||||||
if !os.IsNotExist(err) || dockerHostSet {
|
if !os.IsNotExist(err) || dockerHostSet {
|
||||||
cli, err := client.NewClientWithOpts(client.FromEnv, client.WithAPIVersionNegotiation())
|
cli, err := client.NewClientWithOpts(client.FromEnv, client.WithAPIVersionNegotiation())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("newScript: failed to create docker client")
|
return nil, unlock, fmt.Errorf("newScript: failed to create docker client")
|
||||||
}
|
}
|
||||||
s.cli = cli
|
s.cli = cli
|
||||||
|
s.registerHook(hookLevelPlumbing, func(err error) error {
|
||||||
|
if err := s.cli.Close(); err != nil {
|
||||||
|
return fmt.Errorf("newScript: failed to close docker client: %w", err)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
logFunc := func(logType storage.LogLevel, context string, msg string, params ...any) {
|
logFunc := func(logType storage.LogLevel, context string, msg string, params ...any) {
|
||||||
@@ -168,7 +170,7 @@ func newScript() (*script, error) {
|
|||||||
}
|
}
|
||||||
s3Backend, err := s3.NewStorageBackend(s3Config, logFunc)
|
s3Backend, err := s3.NewStorageBackend(s3Config, logFunc)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("newScript: error creating s3 storage backend: %w", err)
|
return nil, unlock, fmt.Errorf("newScript: error creating s3 storage backend: %w", err)
|
||||||
}
|
}
|
||||||
s.storages = append(s.storages, s3Backend)
|
s.storages = append(s.storages, s3Backend)
|
||||||
}
|
}
|
||||||
@@ -183,7 +185,7 @@ func newScript() (*script, error) {
|
|||||||
}
|
}
|
||||||
webdavBackend, err := webdav.NewStorageBackend(webDavConfig, logFunc)
|
webdavBackend, err := webdav.NewStorageBackend(webDavConfig, logFunc)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("newScript: error creating webdav storage backend: %w", err)
|
return nil, unlock, fmt.Errorf("newScript: error creating webdav storage backend: %w", err)
|
||||||
}
|
}
|
||||||
s.storages = append(s.storages, webdavBackend)
|
s.storages = append(s.storages, webdavBackend)
|
||||||
}
|
}
|
||||||
@@ -200,7 +202,7 @@ func newScript() (*script, error) {
|
|||||||
}
|
}
|
||||||
sshBackend, err := ssh.NewStorageBackend(sshConfig, logFunc)
|
sshBackend, err := ssh.NewStorageBackend(sshConfig, logFunc)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("newScript: error creating ssh storage backend: %w", err)
|
return nil, unlock, fmt.Errorf("newScript: error creating ssh storage backend: %w", err)
|
||||||
}
|
}
|
||||||
s.storages = append(s.storages, sshBackend)
|
s.storages = append(s.storages, sshBackend)
|
||||||
}
|
}
|
||||||
@@ -224,7 +226,7 @@ func newScript() (*script, error) {
|
|||||||
}
|
}
|
||||||
azureBackend, err := azure.NewStorageBackend(azureConfig, logFunc)
|
azureBackend, err := azure.NewStorageBackend(azureConfig, logFunc)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("newScript: error creating azure storage backend: %w", err)
|
return nil, unlock, fmt.Errorf("newScript: error creating azure storage backend: %w", err)
|
||||||
}
|
}
|
||||||
s.storages = append(s.storages, azureBackend)
|
s.storages = append(s.storages, azureBackend)
|
||||||
}
|
}
|
||||||
@@ -241,7 +243,7 @@ func newScript() (*script, error) {
|
|||||||
}
|
}
|
||||||
dropboxBackend, err := dropbox.NewStorageBackend(dropboxConfig, logFunc)
|
dropboxBackend, err := dropbox.NewStorageBackend(dropboxConfig, logFunc)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("newScript: error creating dropbox storage backend: %w", err)
|
return nil, unlock, fmt.Errorf("newScript: error creating dropbox storage backend: %w", err)
|
||||||
}
|
}
|
||||||
s.storages = append(s.storages, dropboxBackend)
|
s.storages = append(s.storages, dropboxBackend)
|
||||||
}
|
}
|
||||||
@@ -267,14 +269,14 @@ func newScript() (*script, error) {
|
|||||||
|
|
||||||
hookLevel, ok := hookLevels[s.c.NotificationLevel]
|
hookLevel, ok := hookLevels[s.c.NotificationLevel]
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("newScript: unknown NOTIFICATION_LEVEL %s", s.c.NotificationLevel)
|
return nil, unlock, fmt.Errorf("newScript: unknown NOTIFICATION_LEVEL %s", s.c.NotificationLevel)
|
||||||
}
|
}
|
||||||
s.hookLevel = hookLevel
|
s.hookLevel = hookLevel
|
||||||
|
|
||||||
if len(s.c.NotificationURLs) > 0 {
|
if len(s.c.NotificationURLs) > 0 {
|
||||||
sender, senderErr := shoutrrr.CreateSender(s.c.NotificationURLs...)
|
sender, senderErr := shoutrrr.CreateSender(s.c.NotificationURLs...)
|
||||||
if senderErr != nil {
|
if senderErr != nil {
|
||||||
return nil, fmt.Errorf("newScript: error creating sender: %w", senderErr)
|
return nil, unlock, fmt.Errorf("newScript: error creating sender: %w", senderErr)
|
||||||
}
|
}
|
||||||
s.sender = sender
|
s.sender = sender
|
||||||
|
|
||||||
@@ -282,13 +284,13 @@ func newScript() (*script, error) {
|
|||||||
tmpl.Funcs(templateHelpers)
|
tmpl.Funcs(templateHelpers)
|
||||||
tmpl, err = tmpl.Parse(defaultNotifications)
|
tmpl, err = tmpl.Parse(defaultNotifications)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("newScript: unable to parse default notifications templates: %w", err)
|
return nil, unlock, fmt.Errorf("newScript: unable to parse default notifications templates: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if fi, err := os.Stat("/etc/dockervolumebackup/notifications.d"); err == nil && fi.IsDir() {
|
if fi, err := os.Stat("/etc/dockervolumebackup/notifications.d"); err == nil && fi.IsDir() {
|
||||||
tmpl, err = tmpl.ParseGlob("/etc/dockervolumebackup/notifications.d/*.*")
|
tmpl, err = tmpl.ParseGlob("/etc/dockervolumebackup/notifications.d/*.*")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("newScript: unable to parse user defined notifications templates: %w", err)
|
return nil, unlock, fmt.Errorf("newScript: unable to parse user defined notifications templates: %w", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
s.template = tmpl
|
s.template = tmpl
|
||||||
@@ -309,7 +311,7 @@ func newScript() (*script, error) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
return s, nil
|
return s, unlock, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// createArchive creates a tar archive of the configured backup location and
|
// createArchive creates a tar archive of the configured backup location and
|
||||||
@@ -507,17 +509,6 @@ func (s *script) pruneBackups() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// must exits the script run prematurely in case the given error
|
|
||||||
// is non-nil.
|
|
||||||
func (s *script) must(err error) {
|
|
||||||
if err != nil {
|
|
||||||
s.logger.Error(
|
|
||||||
fmt.Sprintf("Fatal error running backup: %s", err),
|
|
||||||
)
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// skipPrune returns true if the given backend name is contained in the
|
// skipPrune returns true if the given backend name is contained in the
|
||||||
// list of skipped backends.
|
// list of skipped backends.
|
||||||
func skipPrune(name string, skippedBackends []string) bool {
|
func skipPrune(name string, skippedBackends []string) bool {
|
||||||
|
|||||||
@@ -210,9 +210,9 @@ func (s *script) stopContainersAndServices() (func() error, error) {
|
|||||||
warnings, err := scaleService(s.cli, svc.serviceID, 0)
|
warnings, err := scaleService(s.cli, svc.serviceID, 0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
scaleDownErrors.append(err)
|
scaleDownErrors.append(err)
|
||||||
} else {
|
return
|
||||||
scaledDownServices = append(scaledDownServices, svc)
|
|
||||||
}
|
}
|
||||||
|
scaledDownServices = append(scaledDownServices, svc)
|
||||||
for _, warning := range warnings {
|
for _, warning := range warnings {
|
||||||
s.logger.Warn(
|
s.logger.Warn(
|
||||||
fmt.Sprintf("The Docker API returned a warning when scaling down service %s: %s", svc.serviceID, warning),
|
fmt.Sprintf("The Docker API returned a warning when scaling down service %s: %s", svc.serviceID, warning),
|
||||||
|
|||||||
@@ -13,5 +13,33 @@ If you are interfacing with Docker via TCP, set `DOCKER_HOST` to the correct URL
|
|||||||
DOCKER_HOST=tcp://docker_socket_proxy:2375
|
DOCKER_HOST=tcp://docker_socket_proxy:2375
|
||||||
```
|
```
|
||||||
|
|
||||||
In case you are using a socket proxy, it must support `GET` and `POST` requests to the `/containers` endpoint. If you are using Docker Swarm, it must also support the `/services` endpoint. If you are using pre/post backup commands, it must also support the `/exec` endpoint.
|
If you do this as you seek to restrict access to the Docker socket, this tool is potentially calling the following Docker APIs:
|
||||||
|
|
||||||
|
| API | When |
|
||||||
|
|-|-|
|
||||||
|
| `Info` | always |
|
||||||
|
| `ContainerExecCreate` | running commands from `exec-labels` |
|
||||||
|
| `ContainerExecAttach` | running commands from `exec-labels` |
|
||||||
|
| `ContainerExecInspect` | running commands from `exec-labels` |
|
||||||
|
| `ContainerList` | always |
|
||||||
|
`ServiceList` | Docker engine is running in Swarm mode |
|
||||||
|
| `ServiceInspect` | Docker engine is running in Swarm mode |
|
||||||
|
| `ServiceUpdate` | Docker engine is running in Swarm mode and `stop-during-backup` is used |
|
||||||
|
| `ConatinerStop` | `stop-during-backup` labels are applied to containers |
|
||||||
|
| `ContainerStart` | `stop-during-backup` labels are applied to container |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
In case you are using [`docker-socket-proxy`][proxy], this means following permissions are required:
|
||||||
|
|
||||||
|
| Permission | When |
|
||||||
|
|-|-|
|
||||||
|
| INFO | always required |
|
||||||
|
| CONTAINERS | always required |
|
||||||
|
| POST | required when using `stop-during-backup` or `exec` labels |
|
||||||
|
| EXEC | required when using `exec`-labeled commands |
|
||||||
|
| SERVICES | required when Docker Engine is running in Swarm mode |
|
||||||
|
| NODES | required when labeling services `stop-during-backup` |
|
||||||
|
| TASKS | required when labeling services `stop-during-backup` |
|
||||||
|
|
||||||
|
[proxy]: https://github.com/Tecnativa/docker-socket-proxy
|
||||||
|
|||||||
@@ -23,9 +23,22 @@ You can populate below template according to your requirements and use it as you
|
|||||||
```
|
```
|
||||||
########### BACKUP SCHEDULE
|
########### BACKUP SCHEDULE
|
||||||
|
|
||||||
# Backups run on the given cron schedule in `busybox` flavor. If no
|
|
||||||
# value is set, `@daily` will be used. If you do not want the cron
|
# A cron expression represents a set of times, using 5 or 6 space-separated fields.
|
||||||
# to ever run, use `0 0 5 31 2 ?`.
|
#
|
||||||
|
# Field name | Mandatory? | Allowed values | Allowed special characters
|
||||||
|
# ---------- | ---------- | -------------- | --------------------------
|
||||||
|
# Seconds | No | 0-59 | * / , -
|
||||||
|
# Minutes | Yes | 0-59 | * / , -
|
||||||
|
# Hours | Yes | 0-23 | * / , -
|
||||||
|
# Day of month | Yes | 1-31 | * / , - ?
|
||||||
|
# Month | Yes | 1-12 or JAN-DEC | * / , -
|
||||||
|
# Day of week | Yes | 0-6 or SUN-SAT | * / , - ?
|
||||||
|
#
|
||||||
|
# Month and Day-of-week field values are case insensitive.
|
||||||
|
# "SUN", "Sun", and "sun" are equally accepted.
|
||||||
|
# If no value is set, `@daily` will be used.
|
||||||
|
# If you do not want the cron to ever run, use `0 0 5 31 2 ?`.
|
||||||
|
|
||||||
# BACKUP_CRON_EXPRESSION="0 2 * * *"
|
# BACKUP_CRON_EXPRESSION="0 2 * * *"
|
||||||
|
|
||||||
|
|||||||
@@ -1,26 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
# Copyright 2021 - Offen Authors <hioffen@posteo.de>
|
|
||||||
# SPDX-License-Identifier: MPL-2.0
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
if [ ! -d "/etc/dockervolumebackup/conf.d" ]; then
|
|
||||||
BACKUP_CRON_EXPRESSION="${BACKUP_CRON_EXPRESSION:-@daily}"
|
|
||||||
|
|
||||||
echo "Installing cron.d entry with expression $BACKUP_CRON_EXPRESSION."
|
|
||||||
echo "$BACKUP_CRON_EXPRESSION backup 2>&1" | crontab -
|
|
||||||
else
|
|
||||||
echo "/etc/dockervolumebackup/conf.d was found, using configuration files from this directory."
|
|
||||||
|
|
||||||
crontab -r && crontab /dev/null
|
|
||||||
for file in /etc/dockervolumebackup/conf.d/*; do
|
|
||||||
source $file
|
|
||||||
BACKUP_CRON_EXPRESSION="${BACKUP_CRON_EXPRESSION:-@daily}"
|
|
||||||
echo "Appending cron.d entry with expression $BACKUP_CRON_EXPRESSION and configuration file $file"
|
|
||||||
(crontab -l; echo "$BACKUP_CRON_EXPRESSION /bin/sh -c 'set -a; source $file; set +a && backup' 2>&1") | crontab -
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Starting cron in foreground."
|
|
||||||
crond -f -d 8
|
|
||||||
16
go.mod
16
go.mod
@@ -7,18 +7,20 @@ require (
|
|||||||
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.2.1
|
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.2.1
|
||||||
github.com/containrrr/shoutrrr v0.7.1
|
github.com/containrrr/shoutrrr v0.7.1
|
||||||
github.com/cosiner/argv v0.1.0
|
github.com/cosiner/argv v0.1.0
|
||||||
github.com/docker/cli v24.0.1+incompatible
|
github.com/docker/cli v24.0.9+incompatible
|
||||||
github.com/docker/docker v24.0.7+incompatible
|
github.com/docker/docker v24.0.7+incompatible
|
||||||
github.com/gofrs/flock v0.8.1
|
github.com/gofrs/flock v0.8.1
|
||||||
github.com/klauspost/compress v1.17.5
|
github.com/joho/godotenv v1.5.1
|
||||||
|
github.com/klauspost/compress v1.17.6
|
||||||
github.com/leekchan/timeutil v0.0.0-20150802142658-28917288c48d
|
github.com/leekchan/timeutil v0.0.0-20150802142658-28917288c48d
|
||||||
github.com/minio/minio-go/v7 v7.0.66
|
github.com/minio/minio-go/v7 v7.0.67
|
||||||
github.com/offen/envconfig v1.5.0
|
github.com/offen/envconfig v1.5.0
|
||||||
github.com/otiai10/copy v1.14.0
|
github.com/otiai10/copy v1.14.0
|
||||||
github.com/pkg/sftp v1.13.6
|
github.com/pkg/sftp v1.13.6
|
||||||
|
github.com/robfig/cron/v3 v3.0.1
|
||||||
github.com/studio-b12/gowebdav v0.9.0
|
github.com/studio-b12/gowebdav v0.9.0
|
||||||
golang.org/x/crypto v0.18.0
|
golang.org/x/crypto v0.19.0
|
||||||
golang.org/x/oauth2 v0.16.0
|
golang.org/x/oauth2 v0.17.0
|
||||||
golang.org/x/sync v0.6.0
|
golang.org/x/sync v0.6.0
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -66,8 +68,8 @@ require (
|
|||||||
github.com/pkg/errors v0.9.1 // indirect
|
github.com/pkg/errors v0.9.1 // indirect
|
||||||
github.com/rs/xid v1.5.0 // indirect
|
github.com/rs/xid v1.5.0 // indirect
|
||||||
github.com/sirupsen/logrus v1.9.3 // indirect
|
github.com/sirupsen/logrus v1.9.3 // indirect
|
||||||
golang.org/x/net v0.20.0 // indirect
|
golang.org/x/net v0.21.0 // indirect
|
||||||
golang.org/x/sys v0.16.0 // indirect
|
golang.org/x/sys v0.17.0 // indirect
|
||||||
golang.org/x/text v0.14.0 // indirect
|
golang.org/x/text v0.14.0 // indirect
|
||||||
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect
|
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect
|
||||||
gopkg.in/ini.v1 v1.67.0 // indirect
|
gopkg.in/ini.v1 v1.67.0 // indirect
|
||||||
|
|||||||
36
go.sum
36
go.sum
@@ -253,8 +253,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
|
|||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/dnaeon/go-vcr v1.2.0 h1:zHCHvJYTMh1N7xnV7zf1m1GPBF9Ad0Jk/whtQ1663qI=
|
github.com/dnaeon/go-vcr v1.2.0 h1:zHCHvJYTMh1N7xnV7zf1m1GPBF9Ad0Jk/whtQ1663qI=
|
||||||
github.com/dnaeon/go-vcr v1.2.0/go.mod h1:R4UdLID7HZT3taECzJs4YgbbH6PIGXB6W/sc5OLb6RQ=
|
github.com/dnaeon/go-vcr v1.2.0/go.mod h1:R4UdLID7HZT3taECzJs4YgbbH6PIGXB6W/sc5OLb6RQ=
|
||||||
github.com/docker/cli v24.0.1+incompatible h1:uVl5Xv/39kZJpDo9VaktTOYBc702sdYYF33FqwUG/dM=
|
github.com/docker/cli v24.0.9+incompatible h1:OxbimnP/z+qVjDLpq9wbeFU3Nc30XhSe+LkwYQisD50=
|
||||||
github.com/docker/cli v24.0.1+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8=
|
github.com/docker/cli v24.0.9+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8=
|
||||||
github.com/docker/distribution v2.8.2+incompatible h1:T3de5rq0dB1j30rp0sA2rER+m322EBzniBPB6ZIzuh8=
|
github.com/docker/distribution v2.8.2+incompatible h1:T3de5rq0dB1j30rp0sA2rER+m322EBzniBPB6ZIzuh8=
|
||||||
github.com/docker/distribution v2.8.2+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
|
github.com/docker/distribution v2.8.2+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
|
||||||
github.com/docker/docker v24.0.7+incompatible h1:Wo6l37AuwP3JaMnZa226lzVXGA3F9Ig1seQen0cKYlM=
|
github.com/docker/docker v24.0.7+incompatible h1:Wo6l37AuwP3JaMnZa226lzVXGA3F9Ig1seQen0cKYlM=
|
||||||
@@ -443,6 +443,8 @@ github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:
|
|||||||
github.com/inconshreveable/mousetrap v1.0.1/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
|
github.com/inconshreveable/mousetrap v1.0.1/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
|
||||||
github.com/jarcoal/httpmock v1.2.0 h1:gSvTxxFR/MEMfsGrvRbdfpRUMBStovlSRLw0Ep1bwwc=
|
github.com/jarcoal/httpmock v1.2.0 h1:gSvTxxFR/MEMfsGrvRbdfpRUMBStovlSRLw0Ep1bwwc=
|
||||||
github.com/jarcoal/httpmock v1.2.0/go.mod h1:oCoTsnAz4+UoOUIf5lJOWV2QQIW5UoeUI6aM2YnWAZk=
|
github.com/jarcoal/httpmock v1.2.0/go.mod h1:oCoTsnAz4+UoOUIf5lJOWV2QQIW5UoeUI6aM2YnWAZk=
|
||||||
|
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
|
||||||
|
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
|
||||||
github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4=
|
github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4=
|
||||||
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
|
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
|
||||||
github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
||||||
@@ -456,8 +458,8 @@ github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7V
|
|||||||
github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM=
|
github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM=
|
||||||
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
|
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
|
||||||
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
||||||
github.com/klauspost/compress v1.17.5 h1:d4vBd+7CHydUqpFBgUEKkSdtSugf9YFmSkvUYPquI5E=
|
github.com/klauspost/compress v1.17.6 h1:60eq2E/jlfwQXtvZEeBUYADs+BwKBWURIY+Gj2eRGjI=
|
||||||
github.com/klauspost/compress v1.17.5/go.mod h1:/dCuZOvVtNoHsyb+cuJD3itjs3NbnF6KH9zAO4BDxPM=
|
github.com/klauspost/compress v1.17.6/go.mod h1:/dCuZOvVtNoHsyb+cuJD3itjs3NbnF6KH9zAO4BDxPM=
|
||||||
github.com/klauspost/cpuid/v2 v2.0.1/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
|
github.com/klauspost/cpuid/v2 v2.0.1/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
|
||||||
github.com/klauspost/cpuid/v2 v2.2.6 h1:ndNyv040zDGIDh8thGkXYjnFtiN02M1PVVF+JE/48xc=
|
github.com/klauspost/cpuid/v2 v2.2.6 h1:ndNyv040zDGIDh8thGkXYjnFtiN02M1PVVF+JE/48xc=
|
||||||
github.com/klauspost/cpuid/v2 v2.2.6/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws=
|
github.com/klauspost/cpuid/v2 v2.2.6/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws=
|
||||||
@@ -502,8 +504,8 @@ github.com/miekg/dns v1.1.26/go.mod h1:bPDLeHnStXmXAq1m/Ch/hvfNHr14JKNPMBo3VZKju
|
|||||||
github.com/miekg/dns v1.1.41/go.mod h1:p6aan82bvRIyn+zDIv9xYNUpwa73JcSh9BKwknJysuI=
|
github.com/miekg/dns v1.1.41/go.mod h1:p6aan82bvRIyn+zDIv9xYNUpwa73JcSh9BKwknJysuI=
|
||||||
github.com/minio/md5-simd v1.1.2 h1:Gdi1DZK69+ZVMoNHRXJyNcxrMA4dSxoYHZSQbirFg34=
|
github.com/minio/md5-simd v1.1.2 h1:Gdi1DZK69+ZVMoNHRXJyNcxrMA4dSxoYHZSQbirFg34=
|
||||||
github.com/minio/md5-simd v1.1.2/go.mod h1:MzdKDxYpY2BT9XQFocsiZf/NKVtR7nkE4RoEpN+20RM=
|
github.com/minio/md5-simd v1.1.2/go.mod h1:MzdKDxYpY2BT9XQFocsiZf/NKVtR7nkE4RoEpN+20RM=
|
||||||
github.com/minio/minio-go/v7 v7.0.66 h1:bnTOXOHjOqv/gcMuiVbN9o2ngRItvqE774dG9nq0Dzw=
|
github.com/minio/minio-go/v7 v7.0.67 h1:BeBvZWAS+kRJm1vGTMJYVjKUNoo0FoEt/wUWdUtfmh8=
|
||||||
github.com/minio/minio-go/v7 v7.0.66/go.mod h1:DHAgmyQEGdW3Cif0UooKOyrT3Vxs82zNdV6tkKhRtbs=
|
github.com/minio/minio-go/v7 v7.0.67/go.mod h1:+UXocnUeZ3wHvVh5s95gcrA4YjMIbccT6ubB+1m054A=
|
||||||
github.com/minio/sha256-simd v1.0.1 h1:6kaan5IFmwTNynnKKpDHe6FWHohJOHhCPchzK49dzMM=
|
github.com/minio/sha256-simd v1.0.1 h1:6kaan5IFmwTNynnKKpDHe6FWHohJOHhCPchzK49dzMM=
|
||||||
github.com/minio/sha256-simd v1.0.1/go.mod h1:Pz6AKMiUdngCLpeTL/RJY1M9rUuPMYujV5xJjtbRSN8=
|
github.com/minio/sha256-simd v1.0.1/go.mod h1:Pz6AKMiUdngCLpeTL/RJY1M9rUuPMYujV5xJjtbRSN8=
|
||||||
github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc=
|
github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc=
|
||||||
@@ -593,6 +595,8 @@ github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsT
|
|||||||
github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A=
|
github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A=
|
||||||
github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU=
|
github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU=
|
||||||
github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA=
|
github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA=
|
||||||
|
github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs=
|
||||||
|
github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro=
|
||||||
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
|
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
|
||||||
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
||||||
github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
|
github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
|
||||||
@@ -675,8 +679,8 @@ golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5y
|
|||||||
golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||||
golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
||||||
golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw=
|
golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw=
|
||||||
golang.org/x/crypto v0.18.0 h1:PGVlW0xEltQnzFZ55hkuX5+KLyrMYhHld1YHO4AKcdc=
|
golang.org/x/crypto v0.19.0 h1:ENy+Az/9Y1vSrlrvBSyna3PITt4tiZLf7sgCjZBX7Wo=
|
||||||
golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg=
|
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
|
||||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||||
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||||
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
|
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
|
||||||
@@ -773,8 +777,8 @@ golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug
|
|||||||
golang.org/x/net v0.0.0-20220909164309-bea034e7d591/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk=
|
golang.org/x/net v0.0.0-20220909164309-bea034e7d591/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk=
|
||||||
golang.org/x/net v0.0.0-20221014081412-f15817d10f9b/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk=
|
golang.org/x/net v0.0.0-20221014081412-f15817d10f9b/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk=
|
||||||
golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco=
|
golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco=
|
||||||
golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo=
|
golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4=
|
||||||
golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY=
|
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
|
||||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||||
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||||
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||||
@@ -799,8 +803,8 @@ golang.org/x/oauth2 v0.0.0-20220622183110-fd043fe589d2/go.mod h1:jaDAt6Dkxork7Lm
|
|||||||
golang.org/x/oauth2 v0.0.0-20220822191816-0ebed06d0094/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg=
|
golang.org/x/oauth2 v0.0.0-20220822191816-0ebed06d0094/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg=
|
||||||
golang.org/x/oauth2 v0.0.0-20220909003341-f21342109be1/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg=
|
golang.org/x/oauth2 v0.0.0-20220909003341-f21342109be1/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg=
|
||||||
golang.org/x/oauth2 v0.0.0-20221014153046-6fdb5e3db783/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg=
|
golang.org/x/oauth2 v0.0.0-20221014153046-6fdb5e3db783/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg=
|
||||||
golang.org/x/oauth2 v0.16.0 h1:aDkGMBSYxElaoP81NpoUoz2oo2R2wHdZpGToUxfyQrQ=
|
golang.org/x/oauth2 v0.17.0 h1:6m3ZPmLEFdVxKKWnKq4VqZ60gutO35zm+zrAHVmHyDQ=
|
||||||
golang.org/x/oauth2 v0.16.0/go.mod h1:hqZ+0LWXsiVoZpeld6jVt06P3adbS2Uu911W1SsJv2o=
|
golang.org/x/oauth2 v0.17.0/go.mod h1:OzPDGQiuQMguemayvdylqddI7qcD9lnSDb+1FiwQ5HA=
|
||||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
@@ -913,13 +917,13 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc
|
|||||||
golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU=
|
golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y=
|
||||||
golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||||
golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||||
golang.org/x/term v0.16.0 h1:m+B6fahuftsE9qjo0VWp2FW0mB3MTJvR0BaMQrq0pmE=
|
golang.org/x/term v0.17.0 h1:mkTF7LCd6WGJNL3K1Ad7kwxNfYAW6a8a8QqtMblp/4U=
|
||||||
golang.org/x/term v0.16.0/go.mod h1:yn7UURbUtPyrVJPGPq404EukNFxcm/foM+bV/bfcDsY=
|
golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk=
|
||||||
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
BACKUP_FILENAME="conf.tar.gz"
|
NAME="$EXPANSION_VALUE"
|
||||||
BACKUP_CRON_EXPRESSION="*/1 * * * *"
|
BACKUP_CRON_EXPRESSION="*/1 * * * *"
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
BACKUP_FILENAME="other.tar.gz"
|
NAME="other"
|
||||||
BACKUP_CRON_EXPRESSION="*/1 * * * *"
|
BACKUP_CRON_EXPRESSION="*/1 * * * *"
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
BACKUP_FILENAME="never.tar.gz"
|
NAME="never"
|
||||||
BACKUP_CRON_EXPRESSION="0 0 5 31 2 ?"
|
BACKUP_CRON_EXPRESSION="0 0 5 31 2 ?"
|
||||||
|
|||||||
@@ -4,6 +4,10 @@ services:
|
|||||||
backup:
|
backup:
|
||||||
image: offen/docker-volume-backup:${TEST_VERSION:-canary}
|
image: offen/docker-volume-backup:${TEST_VERSION:-canary}
|
||||||
restart: always
|
restart: always
|
||||||
|
environment:
|
||||||
|
BACKUP_FILENAME: $$NAME.tar.gz
|
||||||
|
BACKUP_FILENAME_EXPAND: 'true'
|
||||||
|
EXPANSION_VALUE: conf
|
||||||
volumes:
|
volumes:
|
||||||
- ${LOCAL_DIR:-./local}:/archive
|
- ${LOCAL_DIR:-./local}:/archive
|
||||||
- app_data:/backup/app_data:ro
|
- app_data:/backup/app_data:ro
|
||||||
|
|||||||
@@ -13,6 +13,8 @@ docker compose up -d --quiet-pull
|
|||||||
# sleep until a backup is guaranteed to have happened on the 1 minute schedule
|
# sleep until a backup is guaranteed to have happened on the 1 minute schedule
|
||||||
sleep 100
|
sleep 100
|
||||||
|
|
||||||
|
docker compose logs backup
|
||||||
|
|
||||||
if [ ! -f "$LOCAL_DIR/conf.tar.gz" ]; then
|
if [ ! -f "$LOCAL_DIR/conf.tar.gz" ]; then
|
||||||
fail "Config from file was not used."
|
fail "Config from file was not used."
|
||||||
fi
|
fi
|
||||||
|
|||||||
23
test/lock/docker-compose.yml
Normal file
23
test/lock/docker-compose.yml
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
version: '3'
|
||||||
|
|
||||||
|
services:
|
||||||
|
backup:
|
||||||
|
image: offen/docker-volume-backup:${TEST_VERSION:-canary}
|
||||||
|
restart: always
|
||||||
|
environment:
|
||||||
|
BACKUP_CRON_EXPRESSION: 0 0 5 31 2 ?
|
||||||
|
BACKUP_RETENTION_DAYS: '7'
|
||||||
|
volumes:
|
||||||
|
- app_data:/backup/app_data:ro
|
||||||
|
- /var/run/docker.sock:/var/run/docker.sock
|
||||||
|
- ${LOCAL_DIR:-./local}:/archive
|
||||||
|
|
||||||
|
offen:
|
||||||
|
image: offen/offen:latest
|
||||||
|
labels:
|
||||||
|
- docker-volume-backup.stop-during-backup=true
|
||||||
|
volumes:
|
||||||
|
- app_data:/var/opt/offen
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
app_data:
|
||||||
34
test/lock/run.sh
Executable file
34
test/lock/run.sh
Executable file
@@ -0,0 +1,34 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
cd "$(dirname "$0")"
|
||||||
|
. ../util.sh
|
||||||
|
current_test=$(basename $(pwd))
|
||||||
|
|
||||||
|
export LOCAL_DIR=$(mktemp -d)
|
||||||
|
|
||||||
|
docker compose up -d --quiet-pull
|
||||||
|
sleep 5
|
||||||
|
|
||||||
|
ec=0
|
||||||
|
|
||||||
|
docker compose exec -e BACKUP_RETENTION_DAYS=7 -e BACKUP_FILENAME=test.tar.gz backup backup & \
|
||||||
|
{ set +e; sleep 0.1; docker compose exec -e BACKUP_FILENAME=test2.tar.gz -e LOCK_TIMEOUT=1s backup backup; ec=$?;}
|
||||||
|
|
||||||
|
if [ "$ec" = "0" ]; then
|
||||||
|
fail "Subsequent invocation exited 0"
|
||||||
|
fi
|
||||||
|
pass "Subsequent invocation did not exit 0"
|
||||||
|
|
||||||
|
sleep 5
|
||||||
|
|
||||||
|
if [ ! -f "${LOCAL_DIR}/test.tar.gz" ]; then
|
||||||
|
fail "Could not find expected tar file"
|
||||||
|
fi
|
||||||
|
pass "Found expected tar file"
|
||||||
|
|
||||||
|
if [ -f "${LOCAL_DIR}/test2.tar.gz" ]; then
|
||||||
|
fail "Subsequent invocation was expected to fail but created archive"
|
||||||
|
fi
|
||||||
|
pass "Subsequent invocation did not create archive"
|
||||||
40
test/proxy/docker-compose.swarm.yml
Normal file
40
test/proxy/docker-compose.swarm.yml
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
# Copyright 2020-2021 - Offen Authors <hioffen@posteo.de>
|
||||||
|
# SPDX-License-Identifier: Unlicense
|
||||||
|
|
||||||
|
version: '3.8'
|
||||||
|
|
||||||
|
services:
|
||||||
|
backup:
|
||||||
|
image: offen/docker-volume-backup:${TEST_VERSION:-canary}
|
||||||
|
environment:
|
||||||
|
BACKUP_FILENAME: test.tar.gz
|
||||||
|
BACKUP_CRON_EXPRESSION: 0 0 5 31 2 ?
|
||||||
|
DOCKER_HOST: tcp://docker_socket_proxy:2375
|
||||||
|
volumes:
|
||||||
|
- pg_data:/backup/pg_data:ro
|
||||||
|
- ${LOCAL_DIR:-local}:/archive
|
||||||
|
|
||||||
|
docker_socket_proxy:
|
||||||
|
image: tecnativa/docker-socket-proxy:0.1
|
||||||
|
environment:
|
||||||
|
INFO: ${ALLOW_INFO:-1}
|
||||||
|
CONTAINERS: ${ALLOW_CONTAINERS:-1}
|
||||||
|
SERVICES: ${ALLOW_SERVICES:-1}
|
||||||
|
POST: ${ALLOW_POST:-1}
|
||||||
|
TASKS: ${ALLOW_TASKS:-1}
|
||||||
|
NODES: ${ALLOW_NODES:-1}
|
||||||
|
volumes:
|
||||||
|
- /var/run/docker.sock:/var/run/docker.sock
|
||||||
|
|
||||||
|
pg:
|
||||||
|
image: postgres:14-alpine
|
||||||
|
environment:
|
||||||
|
POSTGRES_PASSWORD: example
|
||||||
|
volumes:
|
||||||
|
- pg_data:/var/lib/postgresql/data
|
||||||
|
deploy:
|
||||||
|
labels:
|
||||||
|
- docker-volume-backup.stop-during-backup=true
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
pg_data:
|
||||||
36
test/proxy/docker-compose.yml
Normal file
36
test/proxy/docker-compose.yml
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
# Copyright 2020-2021 - Offen Authors <hioffen@posteo.de>
|
||||||
|
# SPDX-License-Identifier: Unlicense
|
||||||
|
|
||||||
|
version: '3.8'
|
||||||
|
|
||||||
|
services:
|
||||||
|
backup:
|
||||||
|
image: offen/docker-volume-backup:${TEST_VERSION:-canary}
|
||||||
|
environment:
|
||||||
|
BACKUP_FILENAME: test.tar.gz
|
||||||
|
BACKUP_CRON_EXPRESSION: 0 0 5 31 2 ?
|
||||||
|
DOCKER_HOST: tcp://docker_socket_proxy:2375
|
||||||
|
volumes:
|
||||||
|
- pg_data:/backup/pg_data:ro
|
||||||
|
- ${LOCAL_DIR:-local}:/archive
|
||||||
|
|
||||||
|
docker_socket_proxy:
|
||||||
|
image: tecnativa/docker-socket-proxy:0.1
|
||||||
|
environment:
|
||||||
|
INFO: ${ALLOW_INFO:-1}
|
||||||
|
CONTAINERS: ${ALLOW_CONTAINERS:-1}
|
||||||
|
POST: ${ALLOW_POST:-1}
|
||||||
|
volumes:
|
||||||
|
- /var/run/docker.sock:/var/run/docker.sock
|
||||||
|
|
||||||
|
pg:
|
||||||
|
image: postgres:14-alpine
|
||||||
|
environment:
|
||||||
|
POSTGRES_PASSWORD: example
|
||||||
|
volumes:
|
||||||
|
- pg_data:/var/lib/postgresql/data
|
||||||
|
labels:
|
||||||
|
- docker-volume-backup.stop-during-backup=true
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
pg_data:
|
||||||
76
test/proxy/run.sh
Executable file
76
test/proxy/run.sh
Executable file
@@ -0,0 +1,76 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
cd $(dirname $0)
|
||||||
|
. ../util.sh
|
||||||
|
current_test=$(basename $(pwd))
|
||||||
|
|
||||||
|
export LOCAL_DIR=$(mktemp -d)
|
||||||
|
|
||||||
|
docker compose up -d --quiet-pull
|
||||||
|
sleep 5
|
||||||
|
|
||||||
|
# The default configuration in docker-compose.yml should
|
||||||
|
# successfully create a backup.
|
||||||
|
docker compose exec backup backup
|
||||||
|
|
||||||
|
sleep 5
|
||||||
|
|
||||||
|
expect_running_containers "3"
|
||||||
|
|
||||||
|
if [ ! -f "$LOCAL_DIR/test.tar.gz" ]; then
|
||||||
|
fail "Archive was not created"
|
||||||
|
fi
|
||||||
|
pass "Found relevant archive file."
|
||||||
|
|
||||||
|
# Disabling POST should make the backup run fail
|
||||||
|
ALLOW_POST="0" docker compose up -d
|
||||||
|
sleep 5
|
||||||
|
|
||||||
|
set +e
|
||||||
|
docker compose exec backup backup
|
||||||
|
if [ $? = "0" ]; then
|
||||||
|
fail "Expected invocation to exit non-zero."
|
||||||
|
fi
|
||||||
|
set -e
|
||||||
|
pass "Invocation exited non-zero."
|
||||||
|
|
||||||
|
docker compose down --volumes
|
||||||
|
|
||||||
|
# Next, the test is run against a Swarm setup
|
||||||
|
|
||||||
|
docker swarm init
|
||||||
|
|
||||||
|
export LOCAL_DIR=$(mktemp -d)
|
||||||
|
|
||||||
|
docker stack deploy --compose-file=docker-compose.swarm.yml test_stack
|
||||||
|
|
||||||
|
sleep 20
|
||||||
|
|
||||||
|
# The default configuration in docker-compose.swarm.yml should
|
||||||
|
# successfully create a backup in Swarm mode.
|
||||||
|
docker exec $(docker ps -q -f name=backup) backup
|
||||||
|
|
||||||
|
if [ ! -f "$LOCAL_DIR/test.tar.gz" ]; then
|
||||||
|
fail "Archive was not created"
|
||||||
|
fi
|
||||||
|
|
||||||
|
pass "Found relevant archive file."
|
||||||
|
|
||||||
|
sleep 5
|
||||||
|
expect_running_containers "3"
|
||||||
|
|
||||||
|
# Disabling POST should make the backup run fail
|
||||||
|
ALLOW_POST="0" docker stack deploy --compose-file=docker-compose.swarm.yml test_stack
|
||||||
|
|
||||||
|
sleep 20
|
||||||
|
|
||||||
|
set +e
|
||||||
|
docker exec $(docker ps -q -f name=backup) backup
|
||||||
|
if [ $? = "0" ]; then
|
||||||
|
fail "Expected invocation to exit non-zero."
|
||||||
|
fi
|
||||||
|
set -e
|
||||||
|
|
||||||
|
pass "Invocation exited non-zero."
|
||||||
Reference in New Issue
Block a user