# File Sync

This page explains how `podrun up` syncs the local project to the remote host with rsync, including the diff preview before overwriting.

## Flow

```mermaid
graph TB
    Start[RsyncToRemote] --> Check{Remote folder empty?}
    Check -->|empty| Sync[rsync -avz --delete]
    Check -->|not empty| Preview[rsync -avni --delete<br/>dry-run]
    Preview --> Changed{Changes?}
    Changed -->|no| Sync
    Changed -->|yes| Ask[Prompt confirm sync? y/N]
    Ask -->|y / Y| Sync
    Ask -->|other| Cancel[Return cancelled]
```

## Diff Preview

When the remote folder already has content, `rsync -avni --delete` runs first and its output is printed. These lines count as "no change" and are skipped:

| Line | Notes |
|---|---|
| Empty line | — |
| `sending ...` / `sent ...` / `total size ...` | rsync summary |
| Starts with `.d..t.......` | Directory timestamp change only |

Any other line counts as a change and requires `y` or `Y` to continue; any other input returns `cancelled` and aborts `up`. A confirmed overwrite writes an `overwrite` record; an empty remote folder writes a `sync` record.

## Sync

The real sync uses `rsync -avz --delete`, so extra remote files are deleted and the remote folder mirrors the local one.

## Exclude List

| Category | Excluded |
|---|---|
| Dependencies | `node_modules/`, `vendor/`, `__pycache__/`, `*.pyc`, `.venv/`, `venv/`, `env/` |
| Version control | `.git/`, `.gitignore` |
| Local files | `.env.local`, `*.log`, `.DS_Store`, `Thumbs.db` |
| Build output | `.next/`, `app/package-lock.json` |

The diff preview also excludes `docker-compose.podrun.yml` so the remote copy is not reported as a change; the real sync does not exclude it, so `--delete` removes the remote copy and [Compose Rewrite](/compose-rewrite) regenerates it afterward.

`.env` is not excluded and is synced to the remote host.

## SSH Behavior

| Item | Setting |
|---|---|
| Authentication | `sshpass -p $PODRUN_PASSWORD` |
| Host key | `StrictHostKeyChecking=no` |
| Remote address | `$PODRUN_USERNAME@$PODRUN_SERVER` |
