# Setup Remote Git Backup (Optional)

## Current Backup Location

**Local Backup Only:**
- Location: `/var/www/html/erp_codearya/.git/`
- Type: Local Git repository
- **⚠️ Important:** This is only stored on your local server. If the server fails, backups are lost.

## Why Remote Backup?

- ✅ **Safety**: Backups stored off-site
- ✅ **Recovery**: Can restore even if server fails
- ✅ **Access**: Access backups from anywhere
- ✅ **Collaboration**: Multiple developers can access

## Setup Remote Backup (GitHub/GitLab)

### Option 1: GitHub (Recommended)

1. **Create a GitHub repository:**
   - Go to https://github.com/new
   - Create a new private repository (e.g., `erp-codearya-backup`)

2. **Add remote and push:**
   ```bash
   cd /var/www/html/erp_codearya
   
   # Add GitHub as remote
   git remote add origin https://github.com/YOUR_USERNAME/erp-codearya-backup.git
   
   # Push all branches and tags
   git push -u origin master
   git push --tags
   ```

3. **Auto-push after each build:**
   ```bash
   # Edit build-with-backup.sh and add at the end:
   git push origin master --tags
   ```

### Option 2: GitLab

1. **Create a GitLab repository:**
   - Go to https://gitlab.com/new
   - Create a new private repository

2. **Add remote and push:**
   ```bash
   git remote add origin https://gitlab.com/YOUR_USERNAME/erp-codearya-backup.git
   git push -u origin master
   git push --tags
   ```

### Option 3: Self-Hosted Git Server

If you have your own Git server:
```bash
git remote add origin git@your-git-server.com:/path/to/repo.git
git push -u origin master
git push --tags
```

## Update Build Script to Auto-Push

Edit `build-with-backup.sh` and add this at the end (after build completes):

```bash
# Push to remote if configured
if git remote | grep -q origin; then
    echo -e "${GREEN}Pushing to remote backup...${NC}"
    git push origin master --tags || {
        echo -e "${YELLOW}Remote push failed. Local backup still available.${NC}"
    }
fi
```

## Check Backup Status

```bash
# Check if remote is configured
git remote -v

# Check backup size
du -sh .git

# View all backups
./list-builds.sh

# Check last push
git log origin/master -1 2>/dev/null || echo "No remote configured"
```

## Security Notes

- **Use private repositories** for production code
- **Don't commit sensitive data** (.env files are already in .gitignore)
- **Use SSH keys** instead of passwords for authentication
- **Enable 2FA** on your Git hosting account

## Current Backup Info

- **Local backup size:** Check with `du -sh .git`
- **Number of builds:** Check with `./list-builds.sh`
- **Remote backup:** Check with `git remote -v`
