==================================================== WINDOWS TO UBUNTU SERVER AUTO-SYNC EXPLANATION ==================================================== Your Setup Architecture: ------------------------ ┌─────────────────┐ ┌─────────────────┐ │ Windows PCs │ ──────> │ Ubuntu Server │ │ (Developers) │ SYNC │ (Database) │ │ - ActivityWatch │ DATA │ - API Endpoint │ │ - Sync Scripts │ │ - MySQL/PostgreSQL │ └─────────────────┘ └─────────────────┘ ==================================================== HOW AUTO-START WORKS: ==================================================== 1. WHEN WINDOWS STARTS: - Windows loads startup items - Finds VBS file in Startup folder - Runs VBS file automatically 2. VBS LAUNCHER RUNS: - Executes silently (no window) - Starts the batch sync script - Keeps it hidden in background 3. BATCH SCRIPT LOOP: - Checks for sync.ps1 file - Runs PowerShell sync script - Waits 5 minutes - Repeats forever 4. POWERSHELL SYNC: - Connects to ActivityWatch (localhost:5600) - Gets activity data - Sends to Ubuntu server - Uses API endpoint on your server ==================================================== AUTO-START LOCATIONS: ==================================================== Windows checks these locations at startup: 1. STARTUP FOLDER (User-specific): %APPDATA%\Microsoft\Windows\Start Menu\Programs\Startup\ - Any .vbs, .bat, .exe here runs at login - Most reliable for user scripts 2. REGISTRY RUN KEY: HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run - Runs programs at user login - Good backup method 3. SCHEDULED TASKS: - Can run at system start (before login) - Can run at user login - Most flexible option ==================================================== VERIFICATION STEPS: ==================================================== To verify auto-start is working: 1. CHECK INSTALLATION: Run: VERIFY-AUTOSTART.bat 2. CHECK AFTER RESTART: - Restart Windows - Wait 2-3 minutes - Open Task Manager - Look for: powershell.exe - Check your Ubuntu server logs 3. CHECK SYNC LOGS: - Look in E:\timesheet\timesheet_new\sync.log - Check timestamps - Verify "Running sync to Ubuntu server..." ==================================================== WHAT EACH FILE DOES: ==================================================== sync.ps1 (in %LOCALAPPDATA%\ActivityWatchSync\) - The main sync script - Contains server URL and credentials - Sends data to Ubuntu server ubuntu-sync-launcher.vbs - Invisible launcher - No console window appears - Starts the batch file ubuntu-server-sync.bat - Continuous loop - Runs sync.ps1 every 5 minutes - Logs activity ==================================================== DEPLOYMENT TO MULTIPLE DEVELOPERS: ==================================================== For each developer machine: 1. Developer runs setup from web form - Downloads personalized sync.ps1 - Contains their API token 2. Run INSTALL-UBUNTU-AUTOSTART.bat - Sets up auto-start - Works on restart 3. Verify with VERIFY-AUTOSTART.bat - Confirms installation - Tests sync ==================================================== TROUBLESHOOTING: ==================================================== Sync not starting on restart? 1. Check Windows Event Viewer - Look for startup errors 2. Check if VBS exists in Startup: dir "%APPDATA%\Microsoft\Windows\Start Menu\Programs\Startup\*.vbs" 3. Manually test VBS: - Go to Startup folder - Double-click the VBS file - Check if sync starts 4. Check antivirus: - May block VBS scripts - Add exception for sync files 5. Run as Administrator: - Some systems need admin rights - For scheduled task creation ==================================================== UBUNTU SERVER REQUIREMENTS: ==================================================== Your Ubuntu server needs: 1. API endpoint at: https://api-timesheet.firsteconomy.com/api/sync 2. Accept POST requests with: - name (developer name) - token (API token) - data (activity events) - timestamp 3. Database to store activities 4. SSL certificate (for HTTPS) ==================================================== The sync will work automatically after Windows restart as long as: ✓ sync.ps1 exists with correct token ✓ ActivityWatch is installed ✓ Auto-start is configured ✓ Ubuntu server is accessible ✓ Network connection exists ====================================================