30 lines
1.3 KiB
Bash
30 lines
1.3 KiB
Bash
#!/usr/bin/env bash
|
|
# Private bridge to the existing crypt/environment validation and rclone flags.
|
|
set -Eeuo pipefail
|
|
LIB_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)
|
|
# shellcheck source=lib/common.sh
|
|
source "$LIB_DIR/common.sh"
|
|
CONFIG_FILE=${1:?Missing config}
|
|
shift
|
|
load_config
|
|
if [[ ${1:-} == space ]]; then
|
|
# Local maintenance requested between components, while the parent holds FD 9.
|
|
[[ /proc/$PPID/fd/9 -ef $LOCKFILE ]] || die 'Space recovery requires the parent backup lock'
|
|
[[ ${2:-} =~ ^[0-9]+$ && $# == 2 ]] || die 'Invalid space request'
|
|
guard_workspaces
|
|
# shellcheck source=lib/space.sh
|
|
source "$LIB_DIR/space.sh"
|
|
clean_backup_scratch
|
|
MIN_FREE_GB=$(python3 -c 'import math,sys; print(math.ceil(float(sys.argv[1])))' "$RESTORE_TEST_MIN_FREE_GB")
|
|
ensure_space "$WORKDIR" "$2"
|
|
exit 0
|
|
fi
|
|
# These reads belong to verification, not upload. Apply the shorter read I/O
|
|
# policy even during crypt preflight. The Python parent owns deadlines/retries
|
|
# and resets partial output before retry; retrying cat here could append bytes.
|
|
RCLONE_TIMEOUT="${RCLONE_CHECK_TIMEOUT}s"
|
|
RCLONE_LOW_LEVEL_RETRIES=$RCLONE_CHECK_LOW_LEVEL_RETRIES
|
|
check_remote >&2
|
|
# rclone is restricted to read operations here, including metadata reads.
|
|
case ${1:-} in lsf|cat) rc "$@" ;; *) die 'Unsupported restore-test remote operation' ;; esac
|