# 10: Syncthing - File Synchronization

Syncthing keeps folders on your devices in sync (PCs, servers, laptops). It’s private, fast, and peer‑to‑peer. For detailed usage and device pairing guides, see the [official Syncthing documentation](https://docs.syncthing.net/).

### Dependency check

- Required: **Docker** (Chapter 3)
- Optional: **Traefik** (Chapter 4) + subdomain (Chapter 4.5) for easy HTTPS access
- Optional: **Borgmatic** (Chapter 6) to back up Syncthing data

## What is Syncthing? (Simple Explanation)

**Syncthing** lets you pick a folder (e.g., Documents) and keep it automatically synchronized between your devices. You choose which devices and folders to sync—nothing is uploaded to third‑party clouds.

## Interdependencies

**Optional but recommended:** **Traefik** for secure HTTPS access with your domain (easier to reach your server). **Borgmatic** will back up Syncthing data as part of your regular backups.

## Prerequisites

- ✅ Docker running (Chapter 3)
- ✅ Optional: Traefik installed (Chapter 4) + subdomain (Chapter 4.5), e.g., `sync.yourdomain.com`
- ✅ Optional: Borgmatic installed (Chapter 6) for backups

## Step 1: Start Infinity Tools

```
sudo infinity-tools
```

## Step 2: Install Syncthing

1. Go to **📱 APPLICATIONS**
2. Select **Syncthing**
3. Choose **Install Syncthing**

### Using the Infinity Tools GUI

- Use **↑/↓** to move, **Enter** to select, **Esc** to go back
- Look for the **turquoise cursor** indicating the current selection
- Each screen shows a short description at the top explaining what’s needed

### Step 2.1: Choose SSL Mode

You’ll be asked how you want to access Syncthing’s web interface:

- **Traefik (recommended)**
    - **What it is:** Use your domain with a trusted HTTPS certificate
    - **What you need:** Subdomain like `sync.yourdomain.com` pointing to your server
    - **What you get:** Clean URL like `https://sync.yourdomain.com`
    - **Pick this if:** You want easy, secure access from anywhere
- **Standalone HTTPS (self‑signed)**
    - **What it is:** HTTPS with a self‑signed certificate (browser warning appears once)
    - **What you need:** A free port (e.g., 8384)
    - **What you get:** URL like `https://SERVER_IP:8384`
    - **Pick this if:** You use it only within your home/office network
- **Standalone HTTP (not encrypted)**
    - **What it is:** Plain HTTP
    - **Pick this only if:** Quick local testing on a private network

**Rule of thumb:** Use **Traefik** if you have a domain. Otherwise use **Standalone HTTPS** for local networks.

## Step 3: Open Syncthing

- **Traefik mode:** Visit `https://sync.yourdomain.com`
- **Standalone:** Visit `https://SERVER_IP:8384` (or the port you chose)

## Step 4: First‑Time Basics

1. **Change the GUI password:** In Settings → GUI, set a username/password
2. **Set the device name:** Give your server a friendly name (e.g., “Home‑Server”)
3. **Create your first folder:** Click “Add Folder” → pick a folder path (e.g., `/opt/speedbits/syncthing/Documents`)

## Step 5: Pair a Device

1. Install Syncthing on your computer/phone (see [official downloads](https://docs.syncthing.net/))
2. On your device, copy the **Device ID** (a long string)
3. On the server web UI, click “Add Remote Device” → paste the Device ID → give it a name
4. Accept the pairing request on the other device
5. Share a folder: Select your folder → “Share With Devices” → pick the device you added

## Step 6: Verify It Works

- Create a test file (e.g., `Test.txt`) in the synced folder on one device
- Within seconds, the file should appear on the other device

## Troubleshooting

- Can’t open the web UI? Check the URL/port and that the Syncthing container is running: `docker ps | grep syncthing`
- Browser warning? That’s normal for self‑signed HTTPS—accept once to proceed
- Folder not syncing? Make sure both devices shared the same folder and have write permissions
- Firewall issues? Ensure ports are open or use Traefik mode for easier access

## Quick Reference

- **Web UI (Traefik):** `https://sync.yourdomain.com`
- **Web UI (Standalone):** `https://SERVER_IP:8384`
- **Change GUI password:** Settings → GUI

You’re ready to keep your files in sync across devices—privately and securely.