#!/bin/sh
# Pull a CIPHERTEXT mirror from the server to this machine (ADR-001 §4),
# so the HDD backups can run here. Only ciphertext crosses the network.
#
#   tools/mirror
. "$(dirname "$0")/lib.sh"
need rsync
[ -n "$CONTINUITY_REMOTE" ] || die "CONTINUITY_REMOTE (user@host) is not set"
umask 077
mkdir -p "$CONTINUITY_DATA"
for d in cipher keys recipients; do
    rsync -a --delete "$CONTINUITY_REMOTE:$CONTINUITY_REMOTE_DATA/$d/" "$CONTINUITY_DATA/$d/"
done
mkdir -p "$MNT"; for c in $CONTINUITY_COMPARTMENTS; do mkdir -p "$MNT/$c"; done
say "mirror of $CONTINUITY_REMOTE updated in $CONTINUITY_DATA"
