From ac28f039bded5b091b8b5d748e434092e7d3b125 Mon Sep 17 00:00:00 2001 From: Spencer Grimes Date: Tue, 31 Mar 2026 13:44:03 -0500 Subject: [PATCH] "vault backup: 2026-03-31 13:44:03 from Flow" --- 21-Server Reference/homelab/README.md | 2 +- .../homelab/stacks/n8n/JW Backup.md | 110 ++++++++++++++++++ .../homelab/stacks/{ => n8n}/n8n.md | 0 3 files changed, 111 insertions(+), 1 deletion(-) create mode 100644 21-Server Reference/homelab/stacks/n8n/JW Backup.md rename 21-Server Reference/homelab/stacks/{ => n8n}/n8n.md (100%) diff --git a/21-Server Reference/homelab/README.md b/21-Server Reference/homelab/README.md index 69da340..068503a 100644 --- a/21-Server Reference/homelab/README.md +++ b/21-Server Reference/homelab/README.md @@ -32,7 +32,7 @@ Living documentation for the `homelab` server. Goal: a new admin with zero prior | [[stacks/gitea]] | Self-hosted Git | [gitea.bunny-wyvern.ts.net](https://gitea.bunny-wyvern.ts.net) | | [[stacks/matrix]] | Matrix homeserver + bridges | [matrix.bunny-wyvern.ts.net](https://matrix.bunny-wyvern.ts.net) | | [[stacks/homepage]] | Dashboard | [homepage.bunny-wyvern.ts.net](https://homepage.bunny-wyvern.ts.net) | -| [[stacks/n8n]] | Workflow automation | [n8n.bunny-wyvern.ts.net](https://n8n.bunny-wyvern.ts.net) | +| [[n8n]] | Workflow automation | [n8n.bunny-wyvern.ts.net](https://n8n.bunny-wyvern.ts.net) | | [[stacks/calibre]] | E-book library (STOPPED) | [calibre.bunny-wyvern.ts.net](https://calibre.bunny-wyvern.ts.net) | | [[stacks/gluetun]] | VPN gateway (Mullvad) | `:8001` (control) | | [[stacks/openproject]] | Project management | [openproject.bunny-wyvern.ts.net](https://openproject.bunny-wyvern.ts.net) | diff --git a/21-Server Reference/homelab/stacks/n8n/JW Backup.md b/21-Server Reference/homelab/stacks/n8n/JW Backup.md new file mode 100644 index 0000000..e4458c9 --- /dev/null +++ b/21-Server Reference/homelab/stacks/n8n/JW Backup.md @@ -0,0 +1,110 @@ +# JW Library Sync System: Architecture & Roadmap +**Date:** 2026-03-31 +**Core Stack:** Android (Tablet/Phone), Tasker, AutoInput, GitSync, Gitea, n8n, jwlFusion. + +--- + +## ## SYSTEM OVERVIEW + +### 1. Local Backup (Tablet & Phone) +* **Trigger:** Time-based (04:30 AM Tablet / 04:35 AM Phone). +* **Action:** Tasker copies the `.jwlibrary` export from the app's export location to the local `vault` directory. +* **Sync:** Tasker uses **AutoInput** to: + 1. Launch GitSync. + 2. Click the "Sync" or "Push" button for the `vault` repository. + 3. Wait for the notification/UI change indicating success. + +### 2. Central Merge (The "Global Truth") +* **Trigger:** Tablet at 04:45 AM. +* **Action:** Tasker sends an **HTTP POST** to the n8n webhook (`bunny-wyvern.ts.net`). +* **n8n Logic:** 1. SSH into the server. + 2. Pull all branch updates from Gitea. + 3. Run `jwlFusion` to merge device backups into `master.jwlibrary`. + 4. Commit and Push the merged file back to Gitea. + 5. Return a `200 OK` "Sync successful" message to Tasker. + +### 3. Restoration (Sync Back) +* **Action:** Upon receiving the `200 OK`, Tasker triggers the `RestoreFromMaster` task. +* **Logic:** GitSync pulls the latest `master.jwlibrary`, and Tasker (via AutoInput or intent) imports it back into the JW Library app. + +--- + +## ## CURRENT CONFIGURATION (POST-INTENT DEPRECATION) +* **GitSync:** Bypassing Intent issues by using **AutoInput** to physically click the sync buttons. +* **Storage:** Vault is located at `/storage/emulated/0/vault` (Shared Storage). +* **Git Settings:** "Safe Directory" and "Credential Store" have been configured in the environment to prevent ownership/password prompts. + +--- + +## ## TO-DO LIST (FOR TOMORROW) + +- [ ] **AutoInput Optimization:** Refine the "Click" sequence in Tasker to ensure it handles the screen being off (using `Turn On` and `Dismiss Keyguard` actions). +- [ ] **Validation Check:** Run a manual end-to-end test: + 1. Manually trigger Tablet Sync. + 2. Manually trigger Phone Sync. + 3. Manually trigger n8n Webhook via Tasker. +- [ ] **Error Handling:** Add a Tasker "Else" condition for the HTTP Request—if n8n returns an error, send a Join/Gotify notification so you know the merge failed. +- [ ] **Gitea Cleanup:** Verify the `.gitignore` in the `vault` folder is correctly ignoring temporary `.tmp` files created during the export process. +- [ ] **Staggering Review:** Confirm if 5 minutes is enough buffer for the Phone to finish its push before the Tablet initiates the Merge Script. + +--- + +## ## FINAL SYSTEM LOGIC (4:30 AM SEQUENCE) +1. **04:30** (Tablet): Tasker -> AutoInput (GitSync Push). +2. **04:35** (Phone): Tasker -> AutoInput (GitSync Push). +3. **04:45** (Tablet): Tasker -> HTTP Request (n8n Webhook). +4. **On Success**: Tasker -> Perform Task (RestoreFromMaster). + + +# DETAILS + +## PROJECT: Automated JW Library Multi-Device Sync (via Gitea/n8n) +**Status:** In Progress (Active Debugging Phase) +**User Persona:** INTJ (Prefers logic-first, no-fluff, technical precision) + +--- + +### 1. THE ARCHITECTURE +The goal is to sync JW Library backups (.jwlibrary) across multiple Android devices using a central "Master" merge script. + +* **Source Devices:** Android Tablet & Phone. +* **Storage:** Local Git "Vault" folder at `/storage/emulated/0/vault`. +* **Git Client:** GitSync (Android App). +* **Remote:** Self-hosted Gitea instance. +* **Orchestration:** n8n (running on `bunny-wyvern.ts.net`). +* **Merge Logic:** `jwlFusion` script on the server. + +--- + +### 2. TECHNICAL HURDLES & CURRENT FIXES +* **Termux Plugin Failure:** The `Termux:Tasker` plugin failed with "Missing/Disabled Receiver" errors (likely due to Android 14 security or Play Store/F-Droid version mismatch). We abandoned Termux scripts for now. +* **GitSync Intent Failure:** Attempted to trigger GitSync via `com.viscouspot.gitsync.action.SYNC` intents, but the app did not respond to background broadcasts. +* **Current Solution:** Using **Tasker + AutoInput**. Tasker wakes the device, opens the GitSync UI, and AutoInput physically clicks "Sync" to ensure the push/pull happens. + +--- + +### 3. THE DAILY TIMELINE (SCHEDULED) +* **04:30 AM (Tablet):** Tasker triggers. AutoInput clicks through GitSync to push the latest local backup to its own branch on Gitea. +* **04:35 AM (Phone):** Same process. Pushes its unique backup to its own branch. +* **04:45 AM (Tablet - Master Trigger):** + 1. Tasker sends an **HTTP POST** to the n8n Webhook. + 2. **n8n Workflow:** * SSH into the server. + * Pull all device branches. + * Run `jwlFusion` to merge everything into `master.jwlibrary`. + * Push `master.jwlibrary` to the `master` branch. + 3. **Restoration:** Once n8n returns `200 OK`, the Tablet (and later the Phone) triggers a "Restore" task to pull the new `master` and import it into JW Library. + +--- + +### 4. AGENT "TO-DO" LIST (FOR NEXT SESSION) +1. **Refine AutoInput:** Ensure the "Sync" clicks are robust (handling screen-off states or unexpected popups). +2. **n8n Webhook Verification:** Confirm the n8n SSH node is correctly executing the `jwlFusion` command and handling Git conflicts. +3. **Restore Logic:** Finalize the Tasker task that takes the pulled `master.jwlibrary` and automates the "Import" into the JW Library app. +4. **Race Condition Check:** Verify the 5-minute stagger between devices is sufficient for GitSync to finish its network operations. + +--- + +### 5. REFERENCE DATA +* **Vault Path:** `/storage/emulated/0/vault` +* **n8n Webhook:** `http://n8n.bunny-wyvern.ts.net:5678/webhook/sync-jw-backup` +* **Personality Context:** User is an INTJ. Provide direct, technical solutions. No fluff. \ No newline at end of file diff --git a/21-Server Reference/homelab/stacks/n8n.md b/21-Server Reference/homelab/stacks/n8n/n8n.md similarity index 100% rename from 21-Server Reference/homelab/stacks/n8n.md rename to 21-Server Reference/homelab/stacks/n8n/n8n.md