Support tilde expansion (e.g. ~/config), check ~/config and /root/config, and stage companion compose files

This commit is contained in:
jschantli committed 2026-09-04 20:38:23 -07:00
1 parent 5c44884c5c
commit 877ff62105
2 files changed
+14 -4

No files matched your search

+11 -2
View File
@@ -88,13 +88,14 @@ async def run_backup_task(
f'echo "=== STEP 1: Creating Hot-Snapshot on Remote VPS ({vps_host}) ==="',
f'mkdir -p "{remote_stage}/pangolin"',
f'''
P_DIR="{p_dir}"
eval P_DIR="{p_dir}"
P_DIR="${{P_DIR/#~/$HOME}}"
if [ ! -d "$P_DIR" ] || [ -z "$(ls -A "$P_DIR" 2>/dev/null)" ]; then
echo "Notice: Configured path $P_DIR is empty or does not exist."
echo "Searching VPS for Pangolin Docker compose stack..."
DETECTED=$(docker inspect --format '{{{{index .Config.Labels "com.docker.compose.project.working_dir"}}}}' $(docker ps -aq --filter "name=pangolin" 2>/dev/null) 2>/dev/null | head -n 1)
if [ -z "$DETECTED" ] || [ ! -d "$DETECTED" ]; then
for candidate in /root/pangolin /opt/pangolin /home/*/pangolin /var/lib/pangolin /srv/pangolin /etc/pangolin; do
for candidate in "$HOME/config" "/root/config" "$HOME/pangolin" "/root/pangolin" "$HOME" "/opt/pangolin" /home/*/pangolin /var/lib/pangolin /srv/pangolin /etc/pangolin; do
if [ -d "$candidate" ] && [ -n "$(ls -A "$candidate" 2>/dev/null)" ]; then
DETECTED="$candidate"
break
@@ -112,6 +113,14 @@ fi
echo "--- Staging Pangolin files from $P_DIR ---"
if [ -d "$P_DIR" ]; then
rsync -av --exclude="*.db" --exclude="*.db-wal" --exclude="*.db-shm" "$P_DIR/" "{remote_stage}/pangolin/"
# If compose or env file lives in parent folder (e.g. ~ when config is ~/config), include them too
PARENT_DIR="$(dirname "$P_DIR")"
for extra in docker-compose.yml compose.yaml docker-compose.yaml .env; do
if [ -f "$PARENT_DIR/$extra" ] && [ ! -f "{remote_stage}/pangolin/$extra" ]; then
echo "--- Staging companion $extra from $PARENT_DIR ---"
cp "$PARENT_DIR/$extra" "{remote_stage}/pangolin/" 2>/dev/null || true
fi
done
fi
echo "--- Performing zero-lock hot-backup of SQLite databases on VPS ---"