#!/usr/bin/env bash #MISE description="Restore the production database locally from the Litestream S3 replica" #MISE confirm="This will overwrite data/music_library_dev.db. Continue?" set -euo pipefail source "$(git rev-parse --show-toplevel)/scripts/_helpers.sh" ensure_working_directory! : "${LITESTREAM_ACCESS_KEY_ID:?must be set}" : "${LITESTREAM_SECRET_ACCESS_KEY:?must be set}" current_date=$(date +%Y-%m-%d_%H-%M-%S) project_dir=$(git rev-parse --show-toplevel) data_dir="$project_dir/data" dest_file="$data_dir/music_library_prod_$current_date.db" replica_db_path="/mnt/music_library/music_library_prod.db" config_file=$(mktemp) trap 'rm -f "$config_file"' EXIT cat >"$config_file" <