Sync-in

February 8, 2026 (1mo ago)

0 views

Sync-in là giải pháp self-hosted để đồng bộ file giữa các thiết bị, tương tự như Syncthing nhưng có giao diện web quản lý. Bài này hướng dẫn cài đặt Sync-in trên NAS chạy Docker.

1. Tạo thư mục lưu trữ

Tạo các thư mục cần thiết cho Sync-in:

sudo mkdir -p /mnt/ssd/syncin-data/storage
sudo mkdir -p /mnt/ssd/syncin-data/mysql
sudo mkdir -p /mnt/ssd/syncin-data/config

Giải thích:

  • storage: Nơi lưu file đồng bộ
  • mysql: Database MariaDB
  • config: File cấu hình

2. Tạo thư mục chứa Docker Compose

sudo mkdir -p /opt/syncin
cd /opt/syncin

3. Tạo file Docker Compose

sudo nano docker-compose.yml

Nội dung:

services:
  syncin:
    image: syncin/server:latest
    container_name: syncin
    restart: unless-stopped
    ports:
      - '9090:8080'
    environment:
      TZ: Asia/Ho_Chi_Minh
      # Tạo admin user lần chạy đầu tiên
      INIT_ADMIN: 'true'
      INIT_ADMIN_LOGIN: 'your_username'
      INIT_ADMIN_PASSWORD: 'your_secure_password'
    volumes:
      - /mnt/ssd/syncin-data/storage:/data/storage
      - /mnt/ssd/syncin-data/config/environment.yaml:/app/server/environment.yaml
    depends_on:
      - db

  db:
    image: mariadb:10.11
    container_name: syncin-db
    restart: unless-stopped
    environment:
      MYSQL_ROOT_PASSWORD: your_root_password
      MYSQL_DATABASE: syncindb
      MYSQL_USER: syncin
      MYSQL_PASSWORD: your_db_password
    volumes:
      - /mnt/ssd/syncin-data/mysql:/var/lib/mysql

Quan trọng: Thay các giá trị your_username, your_secure_password, your_root_password, your_db_password bằng thông tin của bạn. Password nên có ít nhất 12 ký tự, bao gồm chữ hoa, chữ thường, số và ký tự đặc biệt.

4. Tạo file cấu hình environment.yaml

Trước tiên, tạo các secret key ngẫu nhiên:

openssl rand -hex 32

Chạy lệnh này 4-5 lần để có đủ key cho các mục bên dưới.

Tạo file config:

sudo nano /mnt/ssd/syncin-data/config/environment.yaml

Nội dung:

mysql:
  url: mysql://syncin:your_db_password@db:3306/syncindb

server:
  host: 0.0.0.0
  port: 8080
  trustProxy: 1

applications:
  files:
    dataPath: /data/storage

auth:
  encryptionKey: 'your_random_key_1'

token:
  access:
    secret: 'your_random_key_2'
    expireMinutes: 30
  refresh:
    secret: 'your_random_key_3'
    expireDays: 7
  csrf:
    secret: 'your_random_key_4'
  ws:
    secret: 'your_random_key_5'

Lưu ý: Thay your_db_password khớp với password đã đặt trong docker-compose.yml. Các your_random_key_X thay bằng kết quả từ lệnh openssl rand -hex 32.

5. Phân quyền thư mục storage

Sync-in chạy với UID/GID 8888, cần phân quyền đúng:

sudo chown -R 8888:8888 /mnt/ssd/syncin-data/storage
sudo chmod -R 775 /mnt/ssd/syncin-data/storage

6. Khởi chạy Sync-in

cd /opt/syncin
sudo docker compose up -d

Kiểm tra container đã chạy:

docker ps

Nếu thấy syncinsyncin-db đang chạy là OK.

7. Truy cập Web UI

Mở trình duyệt:

http://IP_NAS:9090

Ví dụ: http://192.168.1.197:9090

Đăng nhập bằng username và password đã đặt trong INIT_ADMIN_LOGININIT_ADMIN_PASSWORD.

8. Khắc phục sự cố

Container restart liên tục

Kiểm tra log:

docker logs syncin

Reset hoàn toàn và cài lại từ đầu

Nếu gặp lỗi không sửa được, có thể reset sạch:

cd /opt/syncin
docker compose down -v
sudo rm -rf /mnt/ssd/syncin-data/mysql
sudo rm -rf /mnt/ssd/syncin-data/storage/users

Sau đó chạy lại:

docker compose up -d

Restart sau khi sửa config

docker compose restart syncin

Kết quả

Sau setup, bạn có:

  • Server đồng bộ file self-hosted
  • Giao diện web quản lý tại port 9090
  • Database MariaDB lưu trữ metadata
  • File đồng bộ nằm trong /mnt/ssd/syncin-data/storage