restore.sh (727B)
1 #!/bin/sh 2 3 set -eu 4 5 if [ -z "${BORG_PASSPHRASE:-}" ] 6 then 7 echo "You must set the BORG_PASSPHRASE environment variable first!" 8 echo "You can find it encrypted in the admin-log.git/$HOSTNAME/" 9 exit 1 10 fi 11 12 if [ -z ${1:-} ] 13 then 14 echo "Call with 'spec' or another host/group to select target" 15 exit 1 16 fi 17 18 TARGET="$1" 19 HOSTNAME="pixel.taler-systems.com" 20 echo "Restoring backup for $TARGET from $HOSTNAME" 21 22 REPO="ssh://borg@$HOSTNAME/~/$TARGET-backup" 23 24 LATEST=$(borg list "${REPO}" | awk '{print $1}' | sort -n | tail -n1) 25 26 echo "Latest backup is $LATEST" 27 if [ -z ${LATEST:-} ] 28 then 29 echo "No backups found?" 30 exit 1 31 fi 32 33 borg extract \ 34 --list \ 35 "${REPO}::${LATEST}" \ 36 root/postgres-backup.sql.gz