1
0
mirror of https://github.com/offen/docker-volume-backup.git synced 2025-06-20 06:25:36 +02:00
Files
.github
cmd
backup
testdata
archive.go
command.go
config.go
config_provider.go
config_provider_test.go
copy_archive.go
create_archive.go
encrypt_archive.go
exec.go
hooks.go
lock.go
main.go
notifications.go
notifications.tmpl
profile.go
prune_backups.go
run_script.go
script.go
stats.go
stop_restart.go
stop_restart_test.go
util.go
docs
internal
test
.dockerignore
.editorconfig
.golangci.yml
Dockerfile
LICENSE
README.md
go.mod
go.sum
docker-volume-backup/cmd/backup/copy_archive.go

42 lines
902 B
Go
Raw Normal View History

// Copyright 2024 - offen.software <hioffen@posteo.de>
// SPDX-License-Identifier: MPL-2.0
package main
import (
"os"
"path"
"github.com/offen/docker-volume-backup/internal/errwrap"
"golang.org/x/sync/errgroup"
)
// copyArchive makes sure the backup file is copied to both local and remote locations
// as per the given configuration.
func (s *script) copyArchive() error {
_, name := path.Split(s.file)
if stat, err := os.Stat(s.file); err != nil {
return errwrap.Wrap(err, "unable to stat backup file")
} else {
size := stat.Size()
s.stats.BackupFile = BackupFileStats{
Size: uint64(size),
Name: name,
FullPath: s.file,
}
}
eg := errgroup.Group{}
for _, backend := range s.storages {
b := backend
eg.Go(func() error {
return b.Copy(s.file)
})
}
if err := eg.Wait(); err != nil {
return errwrap.Wrap(err, "error copying archive")
}
return nil
}