deploy: Odroid XU4 이전 서버 설정과 운영 문서 추가
ysscboxx.duckdns.org 서버의 실제 설정을 서버 경로 구조 그대로 보관합니다. - nginx 사이트 설정 (yonggong + Pole Mapper) 과 www-data 실행/LogsDirectory 드롭인 - polemapper.service, 하드웨어 워치독, smartd, fstab (SSD 루트 + SD /boot bind) - Nextcloud 외부 백업 스크립트/타이머 (비밀번호 7z, 14개 보관) 와 설정 예시 - README: SSD 루트 구성과 SD 되돌리기, 상태 감시, 백업/복원, 적용 방법 - docs/deployment.md 에서 이전 서버 문서로 연결 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
215bdb6fca
commit
d4795fbbec
+47
@@ -0,0 +1,47 @@
|
||||
#!/bin/bash
|
||||
# Daily offsite backup of odroid system/app data to Nextcloud as a password-protected 7z.
|
||||
# Restore: 7z x FILE.7z (asks for the archive password)
|
||||
# sudo tar -xzpf backup.tar.gz -C /restore/target
|
||||
set -euo pipefail
|
||||
umask 077
|
||||
source /etc/offsite-backup.conf
|
||||
HOST=$(hostname); TS=$(date +%Y%m%d-%H%M)
|
||||
NAME="$HOST-$TS.7z"
|
||||
WORK=$(mktemp -d /var/tmp/offsite.XXXXXX)
|
||||
trap 'rm -rf "$WORK"' EXIT
|
||||
AUTH=(-u "$SHARE_TOKEN:$SHARE_PASS")
|
||||
|
||||
# metadata + consistent SQLite snapshots (live DB files may be mid-write)
|
||||
mkdir -p "$WORK/meta"
|
||||
dpkg --get-selections > "$WORK/meta/dpkg-selections.txt"
|
||||
lsblk -o NAME,SIZE,FSTYPE,UUID,MOUNTPOINT > "$WORK/meta/lsblk.txt"
|
||||
find /srv -name node_modules -prune -o \( -name "*.db" -o -name "*.sqlite" -o -name "*.sqlite3" \) -type f -print \
|
||||
| grep -v /backups/ | while read -r db; do
|
||||
out="$WORK/meta/sqlite-snapshots$db"; mkdir -p "$(dirname "$out")"
|
||||
sqlite3 "$db" ".backup '$out'"
|
||||
done
|
||||
|
||||
# Supabase (polemapper DB lives there, not on this box)
|
||||
/usr/local/sbin/supabase-export.sh "$WORK/meta/supabase" || echo "WARNING: supabase export failed"
|
||||
|
||||
# tar keeps Linux owners/permissions; 7z adds the password (AES-256, file names hidden too)
|
||||
tar -C / -czpf "$WORK/backup.tar.gz" --warning=no-file-changed --ignore-failed-read \
|
||||
--exclude='*/node_modules' --exclude='*/.next/cache' --exclude='home/*/.cache' --exclude='home/*/.nvm' --exclude='home/*/.npm' --exclude='root/.npm' --exclude='root/.cache' \
|
||||
etc srv usr/local var/spool/cron home root "${WORK#/}/meta" || [ $? -eq 1 ]
|
||||
7z a -t7z -mx=0 -mhe=on -p"$ARCHIVE_PASS" "$WORK/$NAME" "$WORK/backup.tar.gz" >/dev/null
|
||||
SIZE=$(du -h "$WORK/$NAME" | cut -f1)
|
||||
|
||||
curl -sS --fail --retry 3 --retry-delay 30 "${AUTH[@]}" -T "$WORK/$NAME" "$DAV_URL/$NAME"
|
||||
echo "uploaded $NAME ($SIZE)"
|
||||
|
||||
# retention: keep newest $KEEP archives of this host
|
||||
mapfile -t files < <(curl -sS --fail "${AUTH[@]}" -X PROPFIND -H "Depth: 1" "$DAV_URL/" \
|
||||
| grep -o "<d:href>[^<]*</d:href>" | sed -E "s|</?d:href>||g; s|.*/||" \
|
||||
| grep -E "^$HOST-[0-9]{8}-[0-9]{4}\.7z$" | sort)
|
||||
n=${#files[@]}
|
||||
if (( n > KEEP )); then
|
||||
for f in "${files[@]:0:n-KEEP}"; do
|
||||
curl -sS --fail "${AUTH[@]}" -X DELETE "$DAV_URL/$f" && echo "pruned $f"
|
||||
done
|
||||
fi
|
||||
echo "done: $(( n > KEEP ? KEEP : n )) backups on share"
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
#!/bin/bash
|
||||
# Export all Supabase (PostgREST) tables of polemapper as JSON + schema.
|
||||
# Usage: supabase-export.sh OUTDIR (reads SUPABASE_URL / SUPABASE_SERVICE_ROLE_KEY from /srv/polemapper/.env)
|
||||
set -euo pipefail
|
||||
OUT=${1:?outdir}; ENV=/srv/polemapper/.env; PAGE=1000
|
||||
getenv() { grep -E "^$1=" "$ENV" | tail -1 | cut -d= -f2- | tr -d "\"'"; }
|
||||
U=$(getenv SUPABASE_URL); K=$(getenv SUPABASE_SERVICE_ROLE_KEY)
|
||||
[ -n "$U" ] && [ -n "$K" ] || { echo "supabase: credentials not found in $ENV"; exit 1; }
|
||||
H=(-H "apikey: $K" -H "Authorization: Bearer $K")
|
||||
mkdir -p "$OUT"
|
||||
curl -sS --fail "${H[@]}" "$U/rest/v1/" > "$OUT/openapi-schema.json"
|
||||
for t in $(jq -r '.paths | keys[] | select(. != "/" and (startswith("/rpc/")|not)) | ltrimstr("/")' "$OUT/openapi-schema.json"); do
|
||||
order=$(jq -r --arg t "$t" '.definitions[$t].properties | if has("id") then "&order=id.asc" else "" end' "$OUT/openapi-schema.json")
|
||||
off=0; : > "$OUT/$t.ndjson"
|
||||
while :; do
|
||||
page=$(curl -sS --fail "${H[@]}" "$U/rest/v1/$t?select=*$order&limit=$PAGE&offset=$off")
|
||||
n=$(jq 'length' <<<"$page"); jq -c '.[]' <<<"$page" >> "$OUT/$t.ndjson"
|
||||
(( n < PAGE )) && break; off=$((off+PAGE))
|
||||
done
|
||||
jq -s '.' "$OUT/$t.ndjson" > "$OUT/$t.json" && rm "$OUT/$t.ndjson"
|
||||
echo "supabase: $t $(jq length "$OUT/$t.json") rows"
|
||||
done
|
||||
Reference in New Issue
Block a user