Compare commits

...

3 Commits

Author SHA1 Message Date
Frederik Ring
58b42b9036 Supporting proxied Docker APIs through DOCKER_HOST (#70) 2022-02-18 09:08:21 +01:00
Frederik Ring
180438f1fc Update ubuntu image used for running integration tests (#67) 2022-02-15 21:05:03 +01:00
Mauro Molin
30265c14ba Fixed TookTime (#66) 2022-02-14 17:32:05 +01:00
4 changed files with 8 additions and 5 deletions

View File

@@ -3,7 +3,7 @@ version: 2.1
jobs: jobs:
canary: canary:
machine: machine:
image: ubuntu-1604:202007-01 image: ubuntu-2004:202201-02
working_directory: ~/docker-volume-backup working_directory: ~/docker-volume-backup
steps: steps:
- checkout - checkout
@@ -19,6 +19,7 @@ jobs:
name: Run tests name: Run tests
working_directory: ~/docker-volume-backup/test working_directory: ~/docker-volume-backup/test
command: | command: |
export GPG_TTY=$(tty)
./test.sh canary ./test.sh canary
build: build:

View File

@@ -80,7 +80,8 @@ services:
- data:/backup/my-app-backup:ro - data:/backup/my-app-backup:ro
# Mounting the Docker socket allows the script to stop and restart # Mounting the Docker socket allows the script to stop and restart
# the container during backup. You can omit this if you don't want # the container during backup. You can omit this if you don't want
# to stop the container # to stop the container. In case you need to proxy the socket, you can
# also provide a location by setting `DOCKER_HOST` in the container
- /var/run/docker.sock:/var/run/docker.sock:ro - /var/run/docker.sock:/var/run/docker.sock:ro
# If you mount a local directory or volume to `/archive` a local # If you mount a local directory or volume to `/archive` a local
# copy of the backup will be stored there. You can override the # copy of the backup will be stored there. You can override the

View File

@@ -73,7 +73,7 @@ func newScript() (*script, error) {
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.EndTime) s.stats.TookTime = s.stats.EndTime.Sub(s.stats.StartTime)
return nil return nil
}) })
@@ -90,7 +90,8 @@ 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")
if !os.IsNotExist(err) { _, dockerHostSet := os.LookupEnv("DOCKER_HOST")
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, fmt.Errorf("newScript: failed to create docker client")

View File

@@ -32,7 +32,7 @@ docker run --rm -it \
echo "[TEST:PASS] Found relevant files in decrypted and untared remote backups." echo "[TEST:PASS] Found relevant files in decrypted and untared remote backups."
echo 1234secret | gpg -d --yes --passphrase-fd 0 ./local/test-hostnametoken.tar.gz.gpg > ./local/decrypted.tar.gz echo 1234secret | gpg -d --pinentry-mode loopback --yes --passphrase-fd 0 ./local/test-hostnametoken.tar.gz.gpg > ./local/decrypted.tar.gz
tar -xf ./local/decrypted.tar.gz -C /tmp && test -f /tmp/backup/app_data/offen.db tar -xf ./local/decrypted.tar.gz -C /tmp && test -f /tmp/backup/app_data/offen.db
rm ./local/decrypted.tar.gz rm ./local/decrypted.tar.gz
test -L /tmp/backup/app_data/db.link test -L /tmp/backup/app_data/db.link