Select Git revision
10litestream
10litestream 637 B
#!/bin/sh
# Should we even run litestream?
if [ -n "${LITESTREAM_URL}" ]; then
# Query the tabacco configuration to obtain the database path.
db_path=$(tabacco metadb-config --config=${TABACCO_CONF:-/etc/tabacco/metadb.yml} db-uri)
if [ ! -e "${db_path}" ]; then
echo "Database is missing, attempting restore..." >&2
litestream restore --if-replica-exists -o "${db_path}" "${LITESTREAM_URL}"
if [ $? -gt 0 ]; then
echo "Restore failed!" >&2
exit 1
fi
fi
else
# Prevent the litestream service from running.
rm -fr /var/run/s6/etc/services.d/litestream
fi
exit 0