learning_ai_common_plat/AI.dev/SKILLS/backup-main-branch.md
saravanakumardb1 97b6f4b8d1 chore: remove AT&T-specific refs, add dual-network switch script
- Replace hardcoded /Users/sd9235/ paths with $HOME in all SKILLS docs
- Use WORKSPACE_DIR variable in backup-main.sh (auto-resolves from script location)
- Genericize 'Forcepoint CertChecker' / 'corporate proxy' to 'SSL-intercepting proxy'
- Add scripts/switch-network.sh for toggling npm between corporate proxy and home
- No functional code changes — only comments, docs, and paths
2026-02-12 20:34:48 -08:00

81 lines
3.3 KiB
Markdown

# Backup Main Branch Skill
**Description**: Smart backup of main branches across repositories with duplicate detection.
**Script**: `scripts/backup-main.sh`
## What It Does
For each of the 3 repositories:
1. Switches to `main` and pulls latest
2. **Pushes any unpushed main commits** to origin
3. Fetches latest remote backup refs
4. **Skips backup** if HEAD matches the latest `backup/main-*` branch (smart duplicate detection)
5. Creates timestamped `backup/main-YYYY-MM-DD-HHMMSS` branch and pushes it
6. Cleans up old backups (keeps last 7)
7. Prints a **summary table** with: repo name, backup status, total commits, push status, last commit message
## Repositories Covered
- `learning_ai_common_plat`
- `learning_voice_ai_agent`
- `learning_multimodal_memory_agents`
## Quick Start
```bash
# From the learning_ai_common_plat root:
bash scripts/backup-main.sh
```
Or via Windsurf workflow: `/backup-main-branch`
## Example Output
```
━━━ learning_ai_common_plat ━━━
Pulling latest...
Pushing 2 unpushed commit(s) on main...
✅ Main pushed
Creating: backup/main-2026-02-12-201500
✅ Pushed to remote
━━━ learning_voice_ai_agent ━━━
Pulling latest...
✅ Already backed up → backup/main-2026-02-12-201500
┌─────────────────────────────────────────────────────────────────────────────────┐
│ BACKUP SUMMARY 2026-02-12 20:15 │
├──────────────────────────┬──────────────────┬─────────┬────────────┬────────────┤
│ Repository │ Backup Status │ Commits │ Main Push │ Last Commit│
├──────────────────────────┼──────────────────┼─────────┼────────────┼────────────┤
│ learning_ai_common_plat │ ✅ New backup │ 142 │ ✅ 2 pushed│ feat(docs) │
│ learning_voice_ai_agent │ ✅ Already backed│ 387 │ up to date │ fix(blob) │
│ learning_multimodal_... │ ✅ New backup │ 98 │ ✅ 4 pushed│ feat(azure)│
└──────────────────────────┴──────────────────┴─────────┴────────────┴────────────┘
```
## Restoration
```bash
# List available backups
git branch -r | grep "backup/main-"
# Restore from a specific backup
git checkout -b restore-from-backup origin/backup/main-2026-02-12-201500
git switch main
git merge restore-from-backup
```
## Customization
- **Add repos**: Edit `REPOS` array in `scripts/backup-main.sh`
- **Change retention**: Modify `tail -n +8` (keep last N) in the cleanup section
- **Cron**: `0 18 * * * bash $HOME/code/mygh/learning_ai_common_plat/scripts/backup-main.sh`
## Related Skills
- [Debug Service](./debug-service.md) — Backup before major changes
- [Production Readiness](./production-readiness.md) — Backup before releases