#!/bin/bash set -eu usage () { echo echo Usage: ./backup.sh [-h, --help] echo echo This utility extracts a TAR backup of data and logs echo produced by the Taler services running inside this Docker echo Compose setup. The backup is saved in /tmp/YYYY-MM-DD-taler-backup.tar } for helpOpt in "-h" "--help"; do if test "$helpOpt" = "${1:-}"; then usage exit 0 fi done if ! which docker > /dev/null; then echo docker not found. exit 1 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}