From fe045658ab9d6850dc8ea9471470f513ba0a331d Mon Sep 17 00:00:00 2001 From: dtfiedler Date: Thu, 9 May 2024 09:37:40 -0400 Subject: [PATCH] chore(litestream): gracefully exist litestream if replica does not exist --- litestream/docker-entrypoint.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/litestream/docker-entrypoint.sh b/litestream/docker-entrypoint.sh index f24737a..ba9dccd 100644 --- a/litestream/docker-entrypoint.sh +++ b/litestream/docker-entrypoint.sh @@ -6,8 +6,12 @@ ytt --data-values-env TVAL -f /litestream.template.yaml > /litestream.yml # restore if needed echo "Restoring database from backup..." -/usr/local/bin/litestream restore -if-db-not-exists -parallelism 10 -config /litestream.yml $TVAL_LOCAL_DB_PATH/state.db -/usr/local/bin/litestream restore -if-db-not-exists -parallelism 10 -config /litestream.yml $TVAL_LOCAL_DB_PATH/contract.db +if ! /usr/local/bin/litestream restore -if-db-not-exists -if-replica-exists -parallelism 10 -config /litestream.yml $TVAL_LOCAL_DB_PATH/state.db; then + echo "Failed to restore state.db" +fi +if ! /usr/local/bin/litestream restore -if-db-not-exists -if-replica-exists -parallelism 10 -config /litestream.yml $TVAL_LOCAL_DB_PATH/contract.db; then + echo "Failed to restore contract.db" +fi if [[ -n "$WAIT_TIME_SECONDS" ]]; then # Sleep for the number of seconds specified in WAIT_TIME_SECONDS