summaryrefslogtreecommitdiff
path: root/sandcastle/import-backup.sh
blob: 25316117615bec660d1512739566c0238df4465d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/bash

set -eu

usage () {
  echo
  echo Usage: ./import-backup.sh [-h,  --help] backup-tar
  echo 
  echo This utility imports a TAR backup of data and logs
  echo into the Taler services running inside this Docker
  echo Compose setup.
}

for arg in "$@"; do
  if test "$arg" = "--help" -o "$arg" = "-h"; then
    usage
    exit 0
  fi
done

if ! which docker > /dev/null; then
  echo docker not found.
  exit 1
fi

if ! docker images | grep debian | grep stable > /dev/null; then
  echo debian:stable not found.  Please extract backup with custom image.
  exit 2
fi

# No --help/-h given, assume the first argument is the TAR.
BACKUP_TAR="${1:-}"

if test -z $BACKUP_TAR; then
  echo Backup file argument not given.
  exit 1
fi

if ! test -a $BACKUP_TAR; then
  echo File $BACKUP_TAR not found.
  exit 1
fi

docker run \
  -v $BACKUP_TAR:/tmp/backup.tar \
  -v demo_talerdata:/taler-data \
  -v demo_talerlogs:/taler-logs \
  -it debian:stable /bin/bash -c "tar -x -f /tmp/backup.tar"