LibrePortal/scripts/backup/verify/backup_verify.sh
librelad 875a60f90f LibrePortal v0.1.0 — initial release
A free, open, self-hosted app platform (GNU AGPLv3): one-click app deploys,
Traefik reverse proxy with automatic SSL, rootless Docker support, gluetun
VPN routing, and a web dashboard to manage it all.

Free & open forever to self-host; optional paid hosted services fund it.
See PROMISE.md.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

Signed-off-by: librelad <librelad@digitalangels.vip>
2026-05-21 20:37:54 +01:00

39 lines
1.2 KiB
Bash

#!/bin/bash
backupVerifySnapshot()
{
local idx="$1"
local snapshot_id="$2"
local app_name="$3"
if [[ -z "$snapshot_id" ]]; then
isNotice "No snapshot id provided — verification skipped"
return 0
fi
local scratch
scratch=$(mktemp -d -t libreportal-verify-XXXXXX)
sudo chown "$docker_install_user":"$docker_install_user" "$scratch"
isNotice "Verifying ${snapshot_id:0:8} via scratch restore at $scratch"
if ! engineRestoreSnapshot "$idx" "$snapshot_id" "$scratch" "$containers_dir$app_name"; then
isError "Verify restore FAILED for $app_name on $(resticLocationName "$idx")"
sudo rm -rf "$scratch"
return 1
fi
local source_count restored_count
source_count=$(sudo find "$containers_dir$app_name" -type f 2>/dev/null | wc -l)
restored_count=$(sudo find "$scratch$containers_dir$app_name" -type f 2>/dev/null | wc -l)
sudo rm -rf "$scratch"
if [[ "$source_count" -ne "$restored_count" ]]; then
isError "Verify file-count mismatch for $app_name (source=$source_count restored=$restored_count)"
return 1
fi
isSuccessful "Snapshot ${snapshot_id:0:8} verified — file count matches ($source_count)"
}