"vault backup: 2026-03-31 15:15:10 from Flow"
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
#!/bin/bash
|
||||
|
||||
# --- CONFIG ---
|
||||
TARGET_DIR="/home/artanis/Inanis_Vault/JW_Backups"
|
||||
MASTER_NAME="master.jwlibrary"
|
||||
LIB_SOURCE="/usr/local/lib/libjwlCore.so"
|
||||
|
||||
# 1. Environment & Pathing
|
||||
export PATH=$PATH:/usr/local/bin:/usr/bin:/bin
|
||||
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
|
||||
cd "$TARGET_DIR" || exit 1
|
||||
|
||||
# 2. Update Repo
|
||||
git pull origin main
|
||||
|
||||
# 3. Rename messy filenames (Spaces/Brackets)
|
||||
shopt -s nullglob
|
||||
counter=1
|
||||
for f in *.jwlibrary; do
|
||||
if [[ "$f" != "$MASTER_NAME" && "$f" != incoming_* ]]; then
|
||||
mv "$f" "incoming_$counter.jwlibrary"
|
||||
((counter++))
|
||||
fi
|
||||
done
|
||||
shopt -u nullglob
|
||||
|
||||
# 4. Identify standardized files
|
||||
INCOMING_FILES=$(ls incoming_*.jwlibrary 2>/dev/null)
|
||||
|
||||
if [ -z "$INCOMING_FILES" ]; then
|
||||
echo "No new device backups found. Exiting."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# 5. Satisfy Binary & Merge
|
||||
ln -sf "$LIB_SOURCE" ./libjwlCore.so
|
||||
FILE_COUNT=$(echo "$MASTER_NAME $INCOMING_FILES" | wc -w)
|
||||
|
||||
if [ -f "$MASTER_NAME" ] && [ "$FILE_COUNT" -gt 1 ]; then
|
||||
jwlFusion -o:"master_tmp" "$MASTER_NAME" $INCOMING_FILES
|
||||
elif [ ! -f "$MASTER_NAME" ] && [ $(echo "$INCOMING_FILES" | wc -w) -gt 1 ]; then
|
||||
jwlFusion -o:"master_tmp" $INCOMING_FILES
|
||||
else
|
||||
# Recovery: If only 1 file exists and no master, promote it
|
||||
cp $INCOMING_FILES "$MASTER_NAME"
|
||||
echo "Promoted single file to master."
|
||||
fi
|
||||
|
||||
# 6. Cleanup & Finalize
|
||||
rm -f ./libjwlCore.so incoming_*.jwlibrary
|
||||
|
||||
if [ -f "master_tmp.jwlibrary" ]; then
|
||||
mv "master_tmp.jwlibrary" "$MASTER_NAME"
|
||||
fi
|
||||
|
||||
# 7. Git Push
|
||||
if git status --porcelain | grep -q .; then
|
||||
git add -A
|
||||
git commit -m "Automated Sync: $(date +'%Y-%m-%d %H:%M')"
|
||||
git push origin main
|
||||
echo "Sync successful. Master updated and pushed."
|
||||
else
|
||||
echo "No changes detected in master."
|
||||
fi
|
||||
Reference in New Issue
Block a user