Files
labca/restore
Arjan H 0ed9d8eac2 Build and use local docker images for docker-only setup (#41)
For now, the images are still built on the target machine for testing,
in the end they need to be built in a GitHub action.
2023-04-15 09:19:17 +02:00

26 lines
717 B
Bash
Executable File

#!/usr/bin/env bash
set -e
FILE=/opt/backup/$1
[ "$1" != "" ] || (echo "You must provide a backup file name to restore"; exit 1)
[ -f $FILE ] || (echo "Backup file '$FILE' not found"; exit 1)
BASE=$(echo "$FILE" | perl -p0e "s/.*\/(.*).tgz/\1/")
TMPDIR=/tmp/$BASE
cd /tmp
tar xzf $FILE 2>&1
cd /opt/boulder
[ -f $TMPDIR/boulder_sa_integration.sql ] || (echo "MySQL backup file not found"; exit 1)
docker-compose exec -T bmysql mysql boulder_sa_integration <$TMPDIR/boulder_sa_integration.sql
mv -f $TMPDIR/*key* $TMPDIR/*cert.pem $TMPDIR/*.csr /etc/nginx/ssl/
[ -d $TMPDIR/data ] || (echo "Data folder backup not found"; exit 1)
rm -rf /opt/labca/data/* && mv $TMPDIR/data/* /opt/labca/data/
rm -rf $TMPDIR