summaryrefslogtreecommitdiff
path: root/sandcastle/backup.sh
diff options
context:
space:
mode:
Diffstat (limited to 'sandcastle/backup.sh')
-rwxr-xr-xsandcastle/backup.sh42
1 files changed, 42 insertions, 0 deletions
diff --git a/sandcastle/backup.sh b/sandcastle/backup.sh
new file mode 100755
index 0000000..3ad3972
--- /dev/null
+++ b/sandcastle/backup.sh
@@ -0,0 +1,42 @@
+#!/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}