Files
admin/.tasks/minio-imgproxy-vds-migration.md
vitya 86a94d7f9d tasks(vds-migration): decompose umbrella → 3 child tasks
- mssql-vds-migration : Express edition, BACKUP/RESTORE method, mssql.kzntsv.site:1433
- minio-imgproxy-vds-migration : MinIO upgrade 2020→latest, mc mirror, includes imgproxy+nginx
- iis-cutover-to-vds-services 🔵: atomic web.config repoint (1 file → 11 hosts), blocked on both migrations
- umbrella mssql-minio-migration-to-vds 🟢: decomposed (kept for history)

Discovery: 5 prod DBs ≤ 968 MB (Express OK), .ldf logs 12 GB → SHRINKFILE
pre-cutover. VDS: 79 GB free, 5.8 GB RAM avail. ownCloud capped 1G.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-22 09:02:49 +03:00

70 lines
7.8 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# minio-imgproxy-vds-migration
## Goal
Перенести MinIO + imgproxy + imgproxy-nginx контейнеры с [[../entities/windows-recovery-host]] на [[../entities/vds-kzntsv]]. Заодно **upgrade MinIO** с `RELEASE.2020-07-13` (5 лет, куча CVE) на `minio/minio:latest`. Доступ снаружи через `minio.vds.kzntsv.site` (S3 API + console).
Это **MinIO+imgproxy половина** umbrella'ы `mssql-minio-migration-to-vds` (декомпозирована 2026-05-22). Вторая половина — `mssql-vds-migration`.
## Key files / refs
- **Source MinIO:** docker container `minio` на windows-recovery-host, image `minio/minio:RELEASE.2020-07-13T18-09-56Z`, bind `C:\Users\vitya\projects\docker\diskstation\minio\data``/data`, ~3 GB.
- **Source imgproxy:** docker container `imgproxy`, image `darthsim/imgproxy`, port 8787:8080. Зависит от MinIO как S3 backend.
- **Source imgproxy-nginx:** docker container `imgproxy-nginx`, image `nginx:alpine`, port 8788:80. Reverse-proxy перед imgproxy с caching.
- **Target stack:** `/opt/stacks/storage/minio-imgproxy/{docker-compose.yml,.env,data,nginx-cache,nginx.conf}` на VDS.
- **Target MinIO image:** `minio/minio:latest` (или pinned tag `RELEASE.2025-*`).
- **CMS endpoints:**
- MinIO S3: `localhost:9000``minio.vds.kzntsv.site` (HTTPS) для external, `http://minio:9000` для inter-container на VDS через `shared-dbs` network.
- imgproxy: `localhost:8788``imgproxy.kzntsv.site` (если CMS реверс-проксит) или прямо в CMS-template URL.
## Decisions
- **Upgrade MinIO** (user 2026-05-22, conditional «если ничего не сломает»). Migration via `mc mirror old-minio → new-minio`. Если совместимость bucket-format ломается → fallback `aws s3 sync`. **Rollback ready** через сохранённый snapshot bind-mount data.
- **imgproxy + imgproxy-nginx** едут вместе — `IMGPROXY_S3_ENDPOINT` поменять на `http://minio:9000` (internal через `shared-dbs`), не external — экономит latency и не гоняет S3 traffic через traefik.
- **Hostname: `minio.vds.kzntsv.site`** (user 2026-05-22). S3 API + Console на одном subdomain (MinIO 2022+ split на :9000 API + :9001 console — два под-роута через traefik PathPrefix или два subdomain).
## Acceptance
1. **Stack deployed на VDS:**
- `/opt/stacks/storage/minio-imgproxy/docker-compose.yml` — 3 сервиса: `minio`, `imgproxy`, `imgproxy-nginx`.
- `minio``minio/minio:latest`, bind `./data:/data`, env `MINIO_ROOT_USER`/`MINIO_ROOT_PASSWORD` из `pass show minio-vds/root-creds`.
- Networks `proxy` (для traefik) + `shared-dbs` (для inter-container).
2. **Traefik routing:**
- `minio.vds.kzntsv.site` → HTTPS → minio:9000 (S3 API).
- `minio-console.vds.kzntsv.site` → HTTPS → minio:9001 (web UI, basicAuth optional).
- LE certs auto-issued через existing acme.json.
3. **Data migration:**
- Snapshot: `tar czf minio-bind-snapshot-$(date +%Y%m%d).tar.gz C:\Users\vitya\projects\docker\diskstation\minio\data` (3 GB → ~3 GB compressed) — rollback insurance.
- Поднять new MinIO **пустой** на VDS, создать matching buckets.
- `mc alias set old http://localhost:9000 …` + `mc alias set new https://minio.vds.kzntsv.site …`.
- `mc mirror --preserve old/<bucket> new/<bucket>` для каждого bucket.
- **Verify:** `mc ls --recursive old/<b>` vs `mc ls --recursive new/<b>` — diff пустой, total size match (±0 bytes).
- **Fallback при ошибках mc mirror:** `aws s3 sync s3://old/<b> s3://new/<b> --endpoint-url=…`.
4. **imgproxy + imgproxy-nginx подняты на VDS:**
- `IMGPROXY_S3_ENDPOINT=http://minio:9000`, `IMGPROXY_USE_S3=true`, `AWS_ACCESS_KEY_ID`/`AWS_SECRET_ACCESS_KEY` из MinIO creds.
- `imgproxy-nginx` reverse-proxy с caching layer перед imgproxy.
- Сохранить cache path/sizing config с source (`/var/cache/nginx/imgproxy` или эквивалент).
5. **CMS endpoints repointed:**
- MinIO endpoint в CMS config → `minio.vds.kzntsv.site` (или прямо `http://minio:9000` если CMS migrate тоже на VDS позже).
- imgproxy URL pattern в CMS templates → новый адрес.
- Smoke: 8 sites загружают images через imgproxy (admin assets UI + клиентские thumbnails).
6. **Backup pipeline на VDS расширен** (`/opt/stacks/backup/scripts/run.sh`):
- `minio_mirror` ежедневно — либо `mc mirror local→backup-bucket-on-kreknin`, либо `rsync /opt/stacks/storage/minio-imgproxy/data → kreknin`. Recommend rsync — проще и hardlink-friendly.
7. **ntfy push verified** для расширенного pipeline (включает MinIO size/duration).
8. **Source windows-host:** после 48ч uptime на VDS — `docker stop minio imgproxy imgproxy-nginx`, через неделю `docker rm + docker volume rm` (minio bind-dir — оставить tar snapshot ещё месяц).
9. **Documented** в [[../.wiki/concepts/minio-imgproxy-on-vds]] (создать): architecture, MinIO upgrade notes (что сломалось при `mc mirror` если что-то), rollback recipe, migration runbook.
## Open questions
- [ ] **DNS A-records** `minio.vds.kzntsv.site` + `minio-console.vds.kzntsv.site` → VDS IP — REGRU API или manual?
- [ ] **MinIO upgrade compat** — есть ли в bucket'ах metadata format'ы которые новый MinIO не читает? `mc admin info` на source + dry-run `mc mirror --dry-run` для оценки. Если ругается → план B: запустить **тот же** старый MinIO image на VDS, мигрировать as-is, upgrade отдельной таской позже.
- [ ] **imgproxy version** — текущий `darthsim/imgproxy` (no tag = latest на момент pull). Upgrade сразу или сохранить same digest? Рекомендую pin digest sources → use same on VDS, separate upgrade task.
- [ ] **nginx cache size on VDS** — сколько диска готов выделить под `imgproxy-nginx` cache? Текущее consumption на windows — проверить через `du -sh` к bind-mount.
## Risks
- **MinIO format compat (5-year gap):** RELEASE.2020-07-13 → 2025+. `xl.meta` format и erasure-coding mode менялись. `mc mirror` обычно работает (read API stable), но edge-cases возможны. **Mitigation:** snapshot bind-mount + dry-run mirror + fallback aws-s3-sync.
- **imgproxy ENV vars** могли переименоваться между версиями (IMGPROXY_S3_* prefix vs IMGPROXY_OBJECT_STORAGE_*). Проверить current container env (`docker inspect imgproxy`) и сопоставить с current imgproxy docs.
- **External URL change** — клиентские sites которые ссылаются на `localhost:8788/...` или hardcoded image URLs ломаются. Audit обязателен (`grep -r '8788\|localhost:9000' web.config + appsettings`).
- **VDS RAM:** minio idle ~50 MB, imgproxy ~30 MB. Negligible.
- **VDS Disk:** ~3 GB MinIO + nginx cache (5-10 GB?) + imgproxy temp. Total ~15 GB. **Проверить `df -h /opt/stacks` перед стартом.**
- **DNS propagation:** A-record нужно ставить минимум за 1-2ч до cutover (TTL 300 sec default REGRU).
## Notes
- **Зависит от:** `mssql-vds-migration` (нет — независимы).
- **Atomic revert (full):** revert CMS endpoints → windows-host MinIO; на VDS — `docker compose down -v` для minio-imgproxy stack; удалить minio nogi из `run.sh`; remove traefik routes. Snapshot tar — rollback source при необходимости.