# proton-backup

Backup tool for syncing local directories to Proton Drive with rate limiting and resume support.

## Installation

```bash
go build
cp proton-backup ~/bin/
```

## Usage

```bash
proton-backup -source /path/to/backup -remote /proton/drive/path
```

### Options

- `-source` - Local directory to backup (required)
- `-remote` - Remote path on Proton Drive (required)
- `-exclude` - Comma-separated patterns to exclude (default: "thumbs,encoded-video")
- `-rate-limit` - Milliseconds between uploads (default: 2000)
- `-retries` - Number of retries on failure (default: 5)
- `-retry-delay` - Milliseconds to wait before retry (default: 30000)
- `-dry-run` - Show what would be uploaded without uploading
- `-verbose` - Verbose output

## First Run

On first run, you'll be prompted for Proton credentials:

```bash
proton-backup -source /tank/immich/library -remote /backups/immich
```

Credentials are cached in `~/.config/proton-backup/credentials.json`

## Immich Backup

Configured to run daily at 04:00 via systemd timer.

```bash
# Check timer status
systemctl --user status backup-immich-proton.timer

# Start timer
systemctl --user start backup-immich-proton.timer

# Run manually
systemctl --user start backup-immich-proton.service

# View logs
tail -f ~/logs/backup-immich-proton.log
```

## State Tracking

Upload state is tracked in `~/.config/proton-backup/state.db` (SQLite).
Files are identified by path + size + mtime. Only changed files are re-uploaded.

## Rate Limiting

Default: 2 second delay between uploads to avoid Proton's anti-abuse limits.
Exponential backoff on 422/429 errors.
