diff --git a/lib/jeannie/commands.sh b/lib/jeannie/commands.sh index 30ed744..311d017 100644 --- a/lib/jeannie/commands.sh +++ b/lib/jeannie/commands.sh @@ -4573,10 +4573,14 @@ install_homelab_backup_timer() { local offsite_uri="${HOMELAB_BACKUP_OFFSITE_URI:-}" local tmp_env - if [[ -z "${offsite_uri}" && -e "${env_file}" ]]; then + if [[ "${HOMELAB_BACKUP_SKIP_OFFSITE:-false}" != "true" && -z "${offsite_uri}" && -e "${env_file}" ]]; then offsite_uri="$(sudo awk -F= '$1 == "HOMELAB_BACKUP_OFFSITE_URI" { print substr($0, index($0, "=") + 1); exit }' "${env_file}" 2>/dev/null || true)" fi + if [[ "${HOMELAB_BACKUP_SKIP_OFFSITE:-false}" == "true" ]]; then + offsite_uri="" + fi + tmp_env="$(mktemp)" { cat <&2; exit 1; } upload_archive "${archive}" @@ -100,15 +103,19 @@ case "${ACTION}" in --region "${OCI_REGION}" --namespace-name "${NAMESPACE}" --bucket-name "${BUCKET}" \ --name "${object}.sha256" --file "${tmpdir}/archive.sha256" >/dev/null (cd "${tmpdir}" && sha256sum -c archive.sha256) - listing="$(age -d -i "${AGE_KEY_FILE}" "${tmpdir}/archive.tgz.age" | tar -tzf -)" - grep -q 'gitea/latest-gitea-backup.zip' <<<"${listing}" || { + restore_dir="${tmpdir}/restored" + mkdir -p "${restore_dir}" + age -d -i "${AGE_KEY_FILE}" "${tmpdir}/archive.tgz.age" | + tar -xzf - -C "${restore_dir}" --no-same-owner --no-same-permissions + [[ -s "${restore_dir}/gitea/latest-gitea-backup.zip" ]] || { echo 'restore verification failed: Gitea backup is missing from archive.' >&2 exit 1 } - grep -q '^tofu-state/' <<<"${listing}" || { + find "${restore_dir}/tofu-state" -type f -print -quit 2>/dev/null | grep -q . || { echo 'restore verification failed: OpenTofu state is missing from archive.' >&2 exit 1 } - printf 'restore_verification=ok\nobject=%s\n' "${object}" + tar -tzf <(age -d -i "${AGE_KEY_FILE}" "${tmpdir}/archive.tgz.age") >/dev/null + printf 'restore_verification=ok\nobject=%s\nrestored_artifacts=gitea,tofu-state\n' "${object}" ;; esac