summaryrefslogtreecommitdiff
path: root/docker/demo/backup.sh
blob: 0027b557471381a3a1d2000f844d1d5cb4e80f98 (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
#!/bin/bash

set -eu

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

BACKUP_FILE="/tmp/$(date +%Y-%m-%d)-taler-backup.tar"

if test -a $BACKUP_FILE; then 
  echo "Backup file $BACKUP_FILE exists already, please move it and run the script again."
  exit 3 
fi

# 'chown' should still help rootful runs to
# have the TAR owned by the user invoking the command.
docker run \
  -v /tmp:/tmp \
  -v demo_talerdata:/taler-data \
  -v demo_talerlogs:/taler-logs \
  -it debian:stable \
  /bin/bash -c "tar --no-same-owner --no-same-permissions -c -f ${BACKUP_FILE} /taler-data /taler-logs" > /dev/null

echo Backup at: ${BACKUP_FILE}