ansible-taler-exchange

Ansible playbook to deploy a production Taler Exchange
Log | Files | Refs | Submodules | README | LICENSE

commit a3d7c0b8abb3b0bf8ece84b811127ffc0f73e322
parent a882c8087ad27152e5c510109934fc2b835998e3
Author: Christian Grothoff <christian@grothoff.org>
Date:   Sun, 20 Apr 2025 12:09:34 +0200

add restore script

Diffstat:
MREADME | 10++++++++--
Arestore.sh | 36++++++++++++++++++++++++++++++++++++
2 files changed, 44 insertions(+), 2 deletions(-)

diff --git a/README b/README @@ -14,9 +14,15 @@ $ ansible-galaxy collection install community.postgresql The canonical playbooks are run via shell scripts in the top-level directory. -### deploy.sh (playbooks/setup.yml): +### Main setup (restore.sh, deploy.sh) -This script deploys the latest version of a system on a host. +The "restore.sh" script extracts the latest database backup from the +backup server. It should be run before the deploy.sh script to obtain +the latest version of the database to be restored, unless you are +literally setting up a service from scratch (which should be ultra-rare +in production). + +The "deploy.sh" script deploys the latest version of a system on a host. If you are root@rusty.taler-ops.ch, you may be able to: ``` diff --git a/restore.sh b/restore.sh @@ -0,0 +1,36 @@ +#!/bin/sh + +set -eu + +if [ -z "${BORG_PASSPHRASE:-}" ] +then + echo "You must set the BORG_PASSPHRASE environment variable first!" + echo "You can find it encrypted in the admin-log.git/$HOSTNAME/" + exit 1 +fi + +if [ -z ${1:-} ] +then + echo "Call with 'spec' or another host/group to select target" + exit 1 +fi + +TARGET="$1" +HOSTNAME="pixel.taler-systems.com" +echo "Restoring backup for $TARGET from $HOSTNAME" + +REPO="ssh://borg@$HOSTNAME/~/$TARGET-backup" + +LATEST=$(borg list "${REPO}" | awk '{print $1}' | sort -n | tail -n1) + +echo "Latest backup is $LATEST" +if [ -z ${LATEST:-} ] +then + echo "No backups found?" + exit 1 +fi + +borg extract \ + --list \ + "${REPO}::${LATEST}" \ + root/postgres-backup.sql.xz