#!/bin/bash -e cd "$(dirname $0)" DBPATHNEW="$(jq -r '.DBPath' < config.json)" DBPATHPROD="${DBPATHNEW%-new}" DBPATHOLD="$DBPATHPROD-$(date +'%Y%m%d')"; if [ "$DBPATHNEW" = "$DBPATHPROD" ]; then echo 'Cannot use this script in this configuration' >&2 exit -1; fi ./download-publications cp "$DBPATHPROD" "$DBPATHOLD" (xz -9e "$DBPATHOLD" 2>/dev/null || rm -f "$DBPATHOLD")& mv "$DBPATHNEW" "$DBPATHPROD" exit 0