What: Bash-based sync system between WSL and VPS with git/rsync hybrid.
Entry: ~/.vps-sync/sync.sh
~/.vps-sync/
├── sync.sh # Main entrypoint, thin orchestration
├── config.conf # VPS_HOST, VPS_USER, VPS_PASS, paths
├── lib/
│ ├── remote.sh # RemoteExecutor + SyncStrategy abstractions
│ └── deploy_db.py # Standalone Python DB module
├── helpers/
│ └── deploy.sh # Thin wrapper → deploy_db.py
└── exclude.txt # Rsync exclusions (NOTE: .git/ NOT excluded)
Key Modules:
lib/remote.sh— Centralized SSH/rsync transport. Interface:remote_exec(),sync_push(),sync_pull(),strategy_push(),strategy_pull()lib/deploy_db.py— SQLite management for deployment metadata. Testable standalone.
Authentication Flow:
- Scripts check
VPS_PASSenv var. If set → usesshpass, else → plain SSH. lib/remote.shhides this complexity from callers.
Sync Strategy (Git vs Rsync):
strategy_push/pullauto-detect git repos and use appropriate method.do_rsync()in sync.sh consolidates all rsync calls (was duplicated 8+ places).
Deploy Subcommands:
# CORRECT: separate subcommands
~/.vps-sync/sync.sh deploy nginx <project>
~/.vps-sync/sync.sh deploy systemd <project>
# INCORRECT: old behavior (called both)
~/.vps-sync/sync.sh deploy <project>Test a single function:
# Source the lib, test in isolation
source ~/.vps-sync/config.conf
source ~/.vps-sync/lib/remote.sh
remote_exec "ls -la"Check syntax:
bash -n ~/.vps-sync/sync.sh
bash -n ~/.vps-sync/lib/remote.sh
python3 -m py_compile ~/.vps-sync/lib/deploy_db.pyVerify after changes:
# Dry run - check connection first
~/.vps-sync/sync.sh status
# Test push/pull for one project
~/.vps-sync/sync.sh push my-project.git/in exclude.txt: Intentionally commented out — repos sync whole.git/directories.- Logging: Unified
log_msg()in sync.sh with 5 legacy wrappers for compatibility.info()doesn't write to log file. - Deploy DB: Auto-initializes schema.
deploy_db.pyis the source of truth, not the bash wrapper. - Git Identity: Required for
--autocommits. Set globally or commits fail silently in some contexts.
Key vars in config.conf:
VPS_HOST,VPS_PORT,VPS_USER,VPS_PASS— connectionLOCAL_PROJECTS— usually~/projectsVPS_PROJECTS— usually/home/devDOTFILES_DIRS— synced withdotfiles push/pullSSH_OPTS—-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null