:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(hobby): replace minio with seaweedfs (#100887)
Julian Bez242489d39472
diff --git a/.env.services b/.env.servicesindex 252aaabf533a..0103510fad27 100644--- a/.env.services+++ b/.env.services@@ -32,7 +32,7 @@ REDIS_URL=redis://redis7:6379/# KafkaKAFKA_HOSTS=kafka:9092-# Object storage (MinIO)+# Object storage (SeaweedFS)OBJECT_STORAGE_ENDPOINT=http://objectstorage:19000OBJECT_STORAGE_ACCESS_KEY_ID=object_storage_root_userOBJECT_STORAGE_SECRET_ACCESS_KEY=object_storage_root_passworddiff --git a/.github/scripts/trunk-impacted-targets.js b/.github/scripts/trunk-impacted-targets.jsindex b8bb9821dd55..f486dc0606f4 100644--- a/.github/scripts/trunk-impacted-targets.js+++ b/.github/scripts/trunk-impacted-targets.js@@ -666,7 +666,6 @@ const TRIPWIRE_RULES = [['bin/deploy-hobby', HOBBY],['bin/upgrade-hobby', HOBBY],['bin/migrate-storage-hobby', HOBBY],- ['bin/migrate-session-recordings-hobby', HOBBY],// Called by the hobby storage-migration scripts above, so it has to share// their lane.['bin/migrate-minio-to-seaweedfs', HOBBY],diff --git a/AGENTS.md b/AGENTS.mdindex 168f271b981d..ff0c8eecceee 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -193,7 +193,7 @@ Each rule is tagged with what catches a violation.- **A Python `requests` call to GitHub or Slack under `common/`, `ee/`, `posthog/` or `products/` goes through `posthog/egress/`.** `[lint: github-api-calls-go-through-egress, slack-api-calls-go-through-egress]` Route it through the gated, recorded transport.- **Every other call to those hosts is on review.** `[review]` The rules match an inline URL in a Python `requests` call inside those four directories. A URL bound to a variable first, another transport such as `httpx`, another language, or a caller under `tools/` all pass CI.- **Any other third-party API that needs rate-limiting or egress telemetry belongs there too.** `[review]` Add a `<domain>/` incarnation (GitHub is the reference). No semgrep rule covers a new domain, so a raw client for one reaches master unless a reader catches it. `/routing-outbound-api-calls` decides the route and names the reference domain to copy.-- **Object storage is SeaweedFS — do not add new MinIO dependencies.** `[review]` Both S3-compatible stores are SeaweedFS: `objectstorage` (`:19000`, `OBJECT_STORAGE_*`) for general storage, `seaweedfs` (`:8333`, `SESSION_RECORDING_V2_S3_*`) for session replay v2. MinIO survives only as migration tooling in `docker-compose.hobby.yml` and `bin/upgrade-objectstorage`. Do not add compose services, scripts, tests or docs that stand up a `minio/minio` container. Talk to storage through the existing config and a standard S3 client, never a hardcoded endpoint. Note `objectstorage` registers credentials at runtime and returns `InvalidAccessKeyId` until that finishes, so wait for its readiness sentinel rather than the container start.+- **Object storage is SeaweedFS — do not add new MinIO dependencies.** `[review]` Both S3-compatible stores are SeaweedFS: `objectstorage` (`:19000`, `OBJECT_STORAGE_*`) for general storage, `seaweedfs` (`:8333`, `SESSION_RECORDING_V2_S3_*`) for session replay v2. MinIO survives only as one-off salvage tooling: `bin/upgrade-objectstorage` (dev) and `bin/migrate-storage-hobby` (hobby) start a temporary container to read an old MinIO volume. Do not add compose services, scripts, tests or docs that stand up a `minio/minio` container. Talk to storage through the existing config and a standard S3 client, never a hardcoded endpoint. Note `objectstorage` registers credentials at runtime and returns `InvalidAccessKeyId` until that finishes, so wait for its readiness sentinel rather than the container start.### Django admindiff --git a/bin/hobby-installer/core/checks.go b/bin/hobby-installer/core/checks.goindex 8aa338abeb2c..215892f314ad 100644--- a/bin/hobby-installer/core/checks.go+++ b/bin/hobby-installer/core/checks.go@@ -37,9 +37,27 @@ func GetChecks() []Check {{Name: "Disk space available", Run: checkDiskSpace},{Name: "Network connectivity", Run: checkNetwork},{Name: "Docker volumes", Run: checkDockerVolumes},+ {Name: "Object storage", Run: checkObjectStorage},}}+func checkObjectStorage() CheckResult {+ logger := GetLogger()++ if !DirExists("posthog") {+ logger.Debug("posthog directory not found, skipping object storage check")+ return CheckResult{Passed: true, Detail: "new install"}+ }++ warning := GetObjectStorageWarning()+ if warning == "" {+ return CheckResult{Passed: true, Detail: "SeaweedFS"}+ }++ logger.WriteString("⚠ " + warning + "\n")+ return CheckResult{Passed: true, Warning: true, Detail: "legacy MinIO objects need copying"}+}+func checkDocker() CheckResult {logger := GetLogger()logger.WriteString("Checking for Docker...\n")diff --git a/bin/hobby-installer/core/docker.go b/bin/hobby-installer/core/docker.goindex 3ee29f1e5dd8..6172966f3a7b 100644--- a/bin/hobby-installer/core/docker.go+++ b/bin/hobby-installer/core/docker.go@@ -245,6 +245,27 @@ func CheckDockerVolumes() (bool, bool) {return hasPostgres, hasClickhouse}+// Compose prefixes a volume with the project name, so the MinIO volume is+// `<project>_objectstorage`. The SeaweedFS replacement uses `objectstorage-data`, which+// must not match, hence the exact name and suffix test rather than a substring.+func LegacyObjectStorageVolume() string {+ out, err := RunCommand("docker", "volume", "ls", "-q")+ if err != nil {+ return ""+ }+ return findLegacyObjectStorageVolume(strings.Split(out, "\n"))+}++func findLegacyObjectStorageVolume(names []string) string {+ for _, name := range names {+ name = strings.TrimSpace(name)+ if name == "objectstorage" || strings.HasSuffix(name, "_objectstorage") {+ return name+ }+ }+ return ""+}+func AddUserToDockerGroup(user string) error {if err := RequireRoot("add user to docker group"); err != nil {return errdiff --git a/bin/hobby-installer/core/docker_test.go b/bin/hobby-installer/core/docker_test.gonew file mode 100644index 000000000000..f6f82c5acc4e--- /dev/null+++ b/bin/hobby-installer/core/docker_test.go@@ -0,0 +1,47 @@+package core++import "testing"++func TestFindLegacyObjectStorageVolume(t *testing.T) {+ tests := []struct {+ name string+ volumes []string+ want string+ }{+ {+ // The SeaweedFS replacement mounts objectstorage-data. Matching it would make+ // the installer warn forever and point a salvage run at the live volume.+ name: "ignores the seaweedfs volume",+ volumes: []string{"posthog_objectstorage-data", "posthog_postgres-data"},+ want: "",+ },+ {+ name: "finds the compose-prefixed minio volume",+ volumes: []string{"posthog_objectstorage-data", "posthog_objectstorage"},+ want: "posthog_objectstorage",+ },+ {+ name: "finds an unprefixed minio volume",+ volumes: []string{"objectstorage"},+ want: "objectstorage",+ },+ {+ name: "tolerates the blank line docker volume ls leaves",+ volumes: []string{"posthog_objectstorage", ""},+ want: "posthog_objectstorage",+ },+ {+ name: "reports nothing on a new install",+ volumes: []string{},+ want: "",+ },+ }++ for _, tt := range tests {+ t.Run(tt.name, func(t *testing.T) {+ if got := findLegacyObjectStorageVolume(tt.volumes); got != tt.want {+ t.Errorf("findLegacyObjectStorageVolume(%v) = %q, want %q", tt.volumes, got, tt.want)+ }+ })+ }+}diff --git a/bin/hobby-installer/core/env.go b/bin/hobby-installer/core/env.goindex 398bd497ab82..a6f5cbc74e0a 100644--- a/bin/hobby-installer/core/env.go+++ b/bin/hobby-installer/core/env.go@@ -94,6 +94,7 @@ func LoadExistingEnv() map[string]string {"POSTHOG_NODE_TAG","SESSION_RECORDING_V2_METADATA_SWITCHOVER","SESSION_RECORDING_STORAGE_MIGRATED_TO_SEAWEEDFS",+ "OBJECT_STORAGE_MINIO_REMOVED",}for _, key := range keys {diff --git a/bin/hobby-installer/core/upgrade.go b/bin/hobby-installer/core/upgrade.goindex d113ad5d132d..39fdaa00754d 100644--- a/bin/hobby-installer/core/upgrade.go+++ b/bin/hobby-installer/core/upgrade.go@@ -23,8 +23,8 @@ func CheckUpgradeRequirements() (*UpgradeCheck, error) {check.NeedsPostgresMigration = checkPostgres12InCompose()- check.StorageMigrationStatus = ReadEnvValue("SESSION_RECORDING_STORAGE_MIGRATED_TO_SEAWEEDFS")- check.NeedsStorageMigration = check.StorageMigrationStatus == ""+ check.StorageMigrationStatus = ReadEnvValue("OBJECT_STORAGE_MINIO_REMOVED")+ check.NeedsStorageMigration = LegacyObjectStorageVolume() != ""return check, nil}@@ -114,5 +114,30 @@ func RestorePostgres15(backupFile string) error {}func SetStorageMigrationStatus(status string) error {- return AppendToEnv("SESSION_RECORDING_STORAGE_MIGRATED_TO_SEAWEEDFS", status)+ return AppendToEnv("OBJECT_STORAGE_MINIO_REMOVED", status)+}++// This installer starts the new compose file directly, so it never runs bin/upgrade-hobby+// and cannot show that script's prompt. The preflight check carries the warning instead,+// which is why the text lives here rather than in the shell script.+func GetObjectStorageWarning() string {+ volume := LegacyObjectStorageVolume()+ if volume == "" {+ return ""+ }++ return fmt.Sprintf(`OBJECT STORAGE: MinIO is removed++MinIO stopped publishing Docker images, so PostHog now runs SeaweedFS on the+objectstorage service. SeaweedFS starts on a new volume and cannot read the MinIO format.++Your objects stay on disk in volume %s, but the stack stops reading them.+Until you copy them across, exports, uploaded media, error tracking symbol sets and any+session recordings still in MinIO are unavailable. Postgres and ClickHouse are untouched.++After the upgrade, copy them across with:++ ./posthog/bin/migrate-storage-hobby++Details: https://github.com/PostHog/posthog/blob/master/docs/internal/hobby-minio-removal.md`, volume)}diff --git a/bin/migrate-session-recordings-hobby b/bin/migrate-session-recordings-hobbydeleted file mode 100755index 626d72cf43ea..000000000000--- a/bin/migrate-session-recordings-hobby+++ /dev/null@@ -1,61 +0,0 @@-#!/usr/bin/env bash--set -e--echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"-echo "📦 PostHog Session Recording Migration (MinIO → SeaweedFS)"-echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"-echo ""-echo "This script will migrate your existing session recordings from"-echo "MinIO to SeaweedFS storage."-echo ""-echo "⚠️ Important:"-echo " - Keep this script running until completion"-echo " - The migration runs in the background and won't block new recordings"-echo " - You can monitor progress in the output"-echo ""--read -r -p "Do you want to start the migration? [y/N] " response-if [[ ! "$response" =~ ^([yY][eE][sS]|[yY])+$ ]]-then- echo "Migration cancelled."- exit 0-fi--echo ""-echo "🚀 Starting migration..."-echo ""--# Run the migration script inside the plugins container-# Using --no-deps to avoid conflicts with already-running services-docker-compose run --rm --no-deps \- -e OBJECT_STORAGE_ENDPOINT=http://objectstorage:19000 \- -e OBJECT_STORAGE_ACCESS_KEY_ID=object_storage_root_user \- -e OBJECT_STORAGE_SECRET_ACCESS_KEY=object_storage_root_password \- -e SESSION_RECORDING_V2_S3_ENDPOINT=http://seaweedfs:8333 \- -e SESSION_RECORDING_V2_S3_ACCESS_KEY_ID=any \- -e SESSION_RECORDING_V2_S3_SECRET_ACCESS_KEY=any \- plugins \- node nodejs/bin/migrate-minio-to-seaweedfs.js "$@"--if [ $? -eq 0 ]; then- echo ""- echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"- echo "✅ Migration completed successfully!"- echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"- echo ""- echo "To mark the migration as complete in your .env file, run:"- echo ""- echo " sed -i 's/SESSION_RECORDING_STORAGE_MIGRATED_TO_SEAWEEDFS=pending_migration/SESSION_RECORDING_STORAGE_MIGRATED_TO_SEAWEEDFS=completed/' .env"- echo ""-else- echo ""- echo "❌ Migration failed. Check the output above for errors."- echo ""- echo "You can retry by running this script again with --resume:"- echo ""- echo " ./bin/migrate-session-recordings-hobby --resume"- echo ""- exit 1-fi-diff --git a/bin/migrate-storage-hobby b/bin/migrate-storage-hobbyindex ca406b61d861..5aa892e9296a 100755--- a/bin/migrate-storage-hobby+++ b/bin/migrate-storage-hobby@@ -1,81 +1,324 @@#!/usr/bin/env bash+set -e+set -o pipefail++# Copies objects out of the legacy MinIO volume into the SeaweedFS services that replaced+# it. MinIO is no longer a service in docker-compose.hobby.yml, so the source is a+# temporary container mounted on the orphaned volume. Each destination is the store the+# stack actually reads that data from.++MINIO_IMAGE="quay.io/minio/minio:RELEASE.2025-04-22T22-12-26Z"+SOURCE_CONTAINER="posthog-legacy-minio"+S3_KEY="object_storage_root_user"+S3_SECRET="object_storage_root_password"-# Wrapper script for syncing/migrating object storage between MinIO and SeaweedFS (Hobby)-# Runs inside the plugins container with compose network service names.+OBJECTSTORAGE_ENDPOINT="http://objectstorage:19000"+SEAWEEDFS_ENDPOINT="http://seaweedfs:8333"-# All available services+# `service|destination`, in run order. general-storage covers the whole posthog bucket+# apart from session recordings and the query cache, so a prefix no one listed here still+# comes across. source-maps repeats a prefix general-storage already copied, because+# cymbal reads symbol sets from seaweedfs while Django reads them from objectstorage.ALL_SERVICES=(- "query-cache"- "session-recordings"- "session-recordings-lts"- "media-uploads"- "exports"- "source-maps"+ "general-storage|$OBJECTSTORAGE_ENDPOINT"+ "ai-blobs|$OBJECTSTORAGE_ENDPOINT"+ "source-maps|$SEAWEEDFS_ENDPOINT"+ "session-recordings|$SEAWEEDFS_ENDPOINT"+ "session-recordings-lts|$SEAWEEDFS_ENDPOINT")+# Destinations for a single-service run. A named prefix goes to the store the app reads+# it from, so `source-maps` on its own lands where Django looks.+SINGLE_SERVICES=(+ "general-storage|$OBJECTSTORAGE_ENDPOINT"+ "ai-blobs|$OBJECTSTORAGE_ENDPOINT"+ "exports|$OBJECTSTORAGE_ENDPOINT"+ "media-uploads|$OBJECTSTORAGE_ENDPOINT"+ "source-maps|$OBJECTSTORAGE_ENDPOINT"+ "query-cache|$OBJECTSTORAGE_ENDPOINT"+ "session-recordings|$SEAWEEDFS_ENDPOINT"+ "session-recordings-lts|$SEAWEEDFS_ENDPOINT"+)++if command -v docker-compose >/dev/null 2>&1; then+ COMPOSE=(docker-compose)+else+ COMPOSE=(docker compose)+fi++show_help() {+ cat <<'EOF'+Copy hobby object storage out of MinIO into SeaweedFS++PostHog replaced MinIO with SeaweedFS. SeaweedFS starts on a new volume and cannot read+the MinIO format, so your old objects sit in the `objectstorage` volume until this script+copies them across. Run it from the directory that holds your docker-compose.yml, with+the stack up.++A full run copies the whole `posthog` bucket into objectstorage, the `ai-blobs` bucket+into objectstorage, and session recordings into seaweedfs. Symbol sets are copied to both+stores, because cymbal reads them from seaweedfs and Django reads them from objectstorage.+The query cache is skipped, because PostHog rebuilds it.++Usage:+ ./posthog/bin/migrate-storage-hobby Copy everything+ ./posthog/bin/migrate-storage-hobby exports Copy one service+ ./posthog/bin/migrate-storage-hobby --dry-run Show what would be copied+ ./posthog/bin/migrate-storage-hobby --volume <id> Read a specific MinIO volume++Services:+ general-storage, ai-blobs, exports, media-uploads, source-maps, query-cache,+ session-recordings, session-recordings-lts++Options:+ --dry-run List the objects instead of copying them+ --force Overwrite objects that already exist in the destination+ --workers <n> Number of concurrent workers (default: 5)+ --volume <id> MinIO volume to read, if the script picks the wrong one+ --list List the MinIO volumes on this host+EOF+}++# A MinIO data volume always has a .minio.sys directory at its root.+is_minio_volume() {+ docker run --rm -v "$1:/data:ro" alpine test -d /data/.minio.sys 2>/dev/null+}++volume_size() {+ docker run --rm -v "$1:/data:ro" alpine du -sh /data 2>/dev/null | awk '{print $1}' || echo "unknown"+}++minio_volumes() {+ local vol+ while read -r vol; do+ if is_minio_volume "$vol"; then+ echo "$vol"+ fi+ done < <(docker volume ls -q)+}++list_minio_volumes() {+ local vol+ echo "Scanning for MinIO volumes..."+ echo ""+ while read -r vol; do+ [ -z "$vol" ] && continue+ echo " $vol ($(volume_size "$vol"))"+ done < <(minio_volumes)+}++# The hobby stack named its MinIO volume `objectstorage`, which compose prefixes with the+# project name. Anything else on the host — another install, an unrelated MinIO — is not+# this stack's data, and copying it would import another tenant's objects.+detect_minio_volume() {+ local vol candidates=()+ while read -r vol; do+ [ -z "$vol" ] && continue+ if [ "$vol" = "objectstorage" ] || [[ "$vol" == *_objectstorage ]]; then+ candidates+=("$vol")+ fi+ done < <(minio_volumes)++ if [ ${#candidates[@]} -eq 1 ]; then+ echo "${candidates[0]}"+ return 0+ fi++ if [ ${#candidates[@]} -gt 1 ]; then+ echo "❌ This host has more than one legacy objectstorage volume:" >&2+ printf ' %s\n' "${candidates[@]}" >&2+ echo "Pick the one for this install with --volume <id>." >&2+ return 1+ fi++ return 0+}++# The copy runs inside the plugins container, so both endpoints must be reachable on the+# stack's network. Read the network off a running service rather than guessing the compose+# project name.+compose_network() {+ local container+ container=$("${COMPOSE[@]}" ps -q objectstorage 2>/dev/null | head -1)+ if [ -z "$container" ]; then+ return 1+ fi+ docker inspect -f '{{range $k, $v := .NetworkSettings.Networks}}{{$k}}{{"\n"}}{{end}}' "$container" | head -1+}++stop_source() {+ docker rm -f "$SOURCE_CONTAINER" >/dev/null 2>&1 || true+}++start_source() {+ local volume="$1" network="$2"++ stop_source+ trap stop_source EXIT++ docker run -d \+ --name "$SOURCE_CONTAINER" \+ --network "$network" \+ -v "$volume:/data" \+ -e MINIO_ROOT_USER="$S3_KEY" \+ -e MINIO_ROOT_PASSWORD="$S3_SECRET" \+ "$MINIO_IMAGE" \+ server --address ":19000" /data >/dev/null++ for _ in $(seq 1 30); do+ if docker logs "$SOURCE_CONTAINER" 2>&1 | grep -q "API:"; then+ break+ fi+ sleep 1+ done+ sleep 2+}++# NODE_ENV=development clears the migration script's own guard against running outside a+# development environment. The plugins image ships NODE_ENV=production, and both endpoints+# here are inside the stack's network. The migration script exits non-zero if any object+# failed, and set -e stops the run there rather than reporting a clean copy.+run_service() {+ local service="$1" endpoint="$2"++ echo ""+ echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"+ echo "🔄 $service → $endpoint"+ echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"++ "${COMPOSE[@]}" run --rm --no-deps \+ -e NODE_ENV=development \+ -e OBJECT_STORAGE_ENDPOINT="http://$SOURCE_CONTAINER:19000" \+ -e OBJECT_STORAGE_ACCESS_KEY_ID="$S3_KEY" \+ -e OBJECT_STORAGE_SECRET_ACCESS_KEY="$S3_SECRET" \+ -e SESSION_RECORDING_V2_S3_ENDPOINT="$endpoint" \+ -e SESSION_RECORDING_V2_S3_ACCESS_KEY_ID="$S3_KEY" \+ -e SESSION_RECORDING_V2_S3_SECRET_ACCESS_KEY="$S3_SECRET" \+ plugins \+ node nodejs/bin/migrate-minio-to-seaweedfs.js --service "$service" --mode migrate "${EXTRA_ARGS[@]}"+}++destination_for() {+ local service="$1" entry+ for entry in "${SINGLE_SERVICES[@]}"; do+ if [ "${entry%%|*}" = "$service" ]; then+ echo "${entry##*|}"+ return 0+ fi+ done+ return 1+}+SERVICE=""-MODE="sync" # default to bidirectional sync; use --mode migrate to one-way+VOLUME=""+DRY_RUN=falseEXTRA_ARGS=()-# Parse args (supports: <service>, --mode, --dry-run, --force, --workers, --resume, --revert, --conflict)while [[ $# -gt 0 ]]; docase "$1" in- --mode)- MODE="$2"; shift 2 ;;- --dry-run|--force|--resume|--revert)+ --help|-h)+ show_help; exit 0 ;;+ --list)+ list_minio_volumes; exit 0 ;;+ --volume)+ VOLUME="$2"; shift 2 ;;+ --dry-run|-n)+ DRY_RUN=true; EXTRA_ARGS+=("--dry-run"); shift ;;+ --force)EXTRA_ARGS+=("$1"); shift ;;- --workers|--conflict|--service)+ --workers)EXTRA_ARGS+=("$1" "$2"); shift 2 ;;- -n)- EXTRA_ARGS+=("--dry-run"); shift ;;- query-cache|session-recordings|session-recordings-lts|media-uploads|exports|source-maps)- SERVICE="$1"; shift ;;*)- echo "Unknown arg: $1"; exit 1 ;;+ if destination_for "$1" >/dev/null; then+ SERVICE="$1"; shift+ else+ echo "Unknown argument: $1"+ echo "Run with --help to see the services and options."+ exit 1+ fi ;;esacdone-# Build env for endpoints: MinIO (objectstorage) -> source; SeaweedFS -> destination-# We pass these to the script; it will detect via env.-ENV_ARGS=(- -e OBJECT_STORAGE_ENDPOINT=http://objectstorage:19000- -e OBJECT_STORAGE_ACCESS_KEY_ID=object_storage_root_user- -e OBJECT_STORAGE_SECRET_ACCESS_KEY=object_storage_root_password- -e SESSION_RECORDING_V2_S3_ENDPOINT=http://seaweedfs:8333- -e SESSION_RECORDING_V2_S3_ACCESS_KEY_ID=any- -e SESSION_RECORDING_V2_S3_SECRET_ACCESS_KEY=any-)+if [ -z "$VOLUME" ]; then+ VOLUME=$(detect_minio_volume)+fi-run_service() {- local service="$1"- echo "🔄 ${MODE^^}: $service (MinIO ⇄ SeaweedFS)"- docker-compose run --rm --no-deps \- "${ENV_ARGS[@]}" \- plugins \- node nodejs/bin/migrate-minio-to-seaweedfs.js --service "$service" --mode "$MODE" "${EXTRA_ARGS[@]}"- echo ""-}+if [ -z "$VOLUME" ]; then+ echo "No legacy objectstorage volume found on this host, so there is nothing to copy."+ echo "If you moved the data, pass the volume with --volume <id>."+ exit 0+fi-if [ -z "$SERVICE" ]; then- echo "═══════════════════════════════════════════════════════════════"- echo "🔄 $MODE all services between MinIO and SeaweedFS (Hobby)"- echo "═══════════════════════════════════════════════════════════════"- echo ""- for s in "${ALL_SERVICES[@]}"; do- echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"- run_service "$s"- done- echo "═══════════════════════════════════════════════════════════════"- echo "✨ Completed: $MODE all services"- echo "═══════════════════════════════════════════════════════════════"+if ! is_minio_volume "$VOLUME"; then+ echo "❌ Volume $VOLUME holds no MinIO data (no .minio.sys directory)."+ exit 1+fi++NETWORK=$(compose_network || true)+if [ -z "$NETWORK" ]; then+ echo "❌ The objectstorage service is not running."+ echo "Start the stack with 'docker-compose up -d', then run this again."+ exit 1+fi++echo ""+echo "MinIO volume: $VOLUME ($(volume_size "$VOLUME"))"+echo "Stack network: $NETWORK"+if [ "$DRY_RUN" = true ]; then+ echo "Dry run: nothing is copied."+fi+echo ""+read -r -p "Continue? [y/N] " confirm+if [[ ! "$confirm" =~ ^([yY][eE][sS]|[yY])+$ ]]; then+ echo "Cancelled."+ exit 0+fi++echo ""+echo "Starting a temporary MinIO container to read the old volume..."+start_source "$VOLUME" "$NETWORK"++if [ -n "$SERVICE" ]; then+ run_service "$SERVICE" "$(destination_for "$SERVICE")"else- run_service "$SERVICE"- echo "✨ Done!"+ for entry in "${ALL_SERVICES[@]}"; do+ run_service "${entry%%|*}" "${entry##*|}"+ donefi+stop_source+trap - EXIT+echo ""-echo "Usage:"-echo " $0 # Sync all services"-echo " $0 --mode migrate # One-way migrate all services (MinIO → SeaweedFS)"-echo " $0 exports -n # Dry run exports only"+echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"++# Only a complete run that copied something can say the volume is safe to drop. A dry run+# copies nothing, and a single service leaves the rest of the volume behind.+if [ "$DRY_RUN" = true ]; then+ echo "🔍 Dry run finished. Nothing was copied."+ echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"+ echo ""+ echo "Run the same command without --dry-run to copy the objects."+ echo ""+elif [ -n "$SERVICE" ]; then+ echo "✅ Copied $SERVICE"+ echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"+ echo ""+ echo "The rest of the volume is still only in MinIO. Keep volume $VOLUME until you"+ echo "have run this script without a service argument."+ echo ""+else+ echo "✅ Copy finished"+ echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"+ echo ""+ echo "The query cache was skipped, because PostHog rebuilds it."+ echo ""+ echo "Check your exports, media, symbol sets and recordings in PostHog. Once you are"+ echo "sure everything you need is there, free the disk space with:"+ echo ""+ echo " docker volume rm $VOLUME"+ echo ""+ echo "Until you run that, the old objects are still on disk, so there is no rush."+ echo ""+fidiff --git a/bin/upgrade-hobby b/bin/upgrade-hobbyindex 408fc159becf..3f0a34304b79 100755--- a/bin/upgrade-hobby+++ b/bin/upgrade-hobby@@ -164,65 +164,56 @@ if [ -t 0 ] && ! grep -qE "^OPENAI_API_KEY=.+" .env; thenfifi-# Check if session recording storage migration marker exists-if ! grep -q "SESSION_RECORDING_STORAGE_MIGRATED_TO_SEAWEEDFS" .env; then+# MinIO is no longer in the stack. This asks for a decision while the old stack still+# runs, because the objects cannot be moved after the swap without a temporary MinIO+# container. The marker also covers the older SESSION_RECORDING_STORAGE_MIGRATED_TO_SEAWEEDFS+# prompt, whose migration script read the same MinIO service.+if ! grep -q "OBJECT_STORAGE_MINIO_REMOVED" .env; thenecho ""echo ""echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"- echo "📦 SESSION RECORDING STORAGE UPDATE"+ echo "📦 OBJECT STORAGE UPDATE: MinIO is removed"echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"echo ""- echo "PostHog now uses SeaweedFS for session recording storage."- echo "Your existing session recordings are stored in MinIO."+ echo "MinIO stopped publishing Docker images, so this version replaces it with"+ echo "SeaweedFS. SeaweedFS starts on a new volume and cannot read the MinIO format."echo ""- echo "You have TWO options:"+ echo "Your objects stay on disk in the 'objectstorage' volume, but the stack stops"+ echo "reading them. Until you copy them across, these are unavailable:"echo ""- echo "1. 🔄 MIGRATE your existing session recordings to SeaweedFS"- echo " - Keeps all your existing recordings accessible"- echo " - Run migration script after upgrade"- echo " - New recordings will be stored in SeaweedFS"- echo " - Migration is best-effort for hobby deployments; support is limited"+ echo " - exported assets (CSV, PNG, PDF, video)"+ echo " - uploaded media, such as images in notebooks"+ echo " - error tracking symbol sets"+ echo " - session recordings that are still in MinIO"echo ""- echo "2. ⚠️ ACCEPT DATA LOSS of existing session recordings"- echo " - Existing recordings will become inaccessible"- echo " - Only new recordings will be available"- echo " - Faster upgrade, no migration needed"+ echo "Postgres and ClickHouse are untouched, so events, persons, insights, dashboards,"+ echo "feature flags and experiments all survive the upgrade."+ echo ""+ echo "You have two options:"+ echo ""+ echo "1. ⏸ Stop here and stay on your current version."+ echo " Copy the objects out of MinIO yourself, then run this upgrade again."+ echo ""+ echo "2. ▶️ Continue the upgrade."+ echo " The old volume is kept. Copy the objects into SeaweedFS afterwards with:"+ echo ""+ echo " ./posthog/bin/migrate-storage-hobby"+ echo ""+ echo " Run it from this directory. It reads the old volume through a temporary MinIO"+ echo " container, so it pulls the MinIO image once."+ echo ""+ echo "Both options are described in detail here:"+ echo "https://github.com/PostHog/posthog/blob/master/docs/internal/hobby-minio-removal.md"echo ""echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"echo ""- read -r -p "Do you want to MIGRATE existing session recordings? [y/N] " response- if [[ "$response" =~ ^([yY][eE][sS]|[yY])+$ ]]+ read -r -p "Continue the upgrade? [y/N] " response+ if [[ ! "$response" =~ ^([yY][eE][sS]|[yY])+$ ]]then- echo ""- echo "✅ You chose to MIGRATE existing recordings."- echo ""- echo "After the upgrade completes, run this command to migrate:"- echo ""- echo " ./bin/migrate-session-recordings-hobby"- echo ""- echo "Options:"- echo " --dry-run Preview what would be migrated"- echo " --resume Resume from last checkpoint if interrupted"- echo " --force Overwrite existing objects in destination"- echo " --workers <n> Number of concurrent workers (default: 5)"- echo ""- read -r -p "Press ENTER to acknowledge and continue..."- echo "SESSION_RECORDING_STORAGE_MIGRATED_TO_SEAWEEDFS=pending_migration" >> .env- else- echo ""- echo "⚠️ You chose to ACCEPT DATA LOSS."- echo "Existing session recordings will not be accessible after upgrade."- echo ""- read -r -p "Are you sure? This cannot be undone. [y/N] " confirm- if [[ "$confirm" =~ ^([yY][eE][sS]|[yY])+$ ]]- then- echo "SESSION_RECORDING_STORAGE_MIGRATED_TO_SEAWEEDFS=data_loss_accepted" >> .env- echo "✅ Proceeding without migration."- else- echo "Upgrade cancelled. No changes made."- exit 1- fi+ echo "Upgrade cancelled. No changes made."+ exit 1fi+ echo "OBJECT_STORAGE_MINIO_REMOVED=acknowledged" >> .envsource .envfidiff --git a/docker-compose.hobby.yml b/docker-compose.hobby.ymlindex 2e69598fed3f..244f56e490d8 100644--- a/docker-compose.hobby.yml+++ b/docker-compose.hobby.yml@@ -357,22 +357,48 @@ services:- web- livestreamobjectstorage:- # Transitional legacy MinIO source for hobby migrations.- # Dev/CI stacks use SeaweedFS-backed objectstorage from docker-compose.base.yml,- # but hobby keeps MinIO so bin/migrate-storage-hobby still has a MinIO source.- image: quay.io/minio/minio:RELEASE.2025-04-22T22-12-26Z+ # SeaweedFS on the same objectstorage:19000 endpoint and credentials this service+ # served when it ran MinIO, so no other service in this file changes.+ extends:+ file: docker-compose.base.yml+ service: objectstoragerestart: on-failure- environment:- MINIO_ROOT_USER: object_storage_root_user- MINIO_ROOT_PASSWORD: object_storage_root_password- entrypoint: sh- command: -c 'mkdir -p /data/posthog /data/ducklake-dev /data/ai-blobs && minio server --address ":19000" --console-address ":19001" /data'logging: *default-logging+ # The dev/CI bootstrap this replaces also registers an `anonymous` identity with+ # Admin rights. Hobby must not, because Caddy proxies /posthog/* straight to this+ # service: an anonymous identity opens every object to the internet. With only the+ # posthog identity, SeaweedFS rejects unsigned requests and the presigned URLs+ # Django hands out keep working. There is no duckgres here, so there is no+ # ducklake-dev bucket either. The loop holds no shell variables on purpose:+ # bin/upgrade-hobby pipes this file through envsubst, which collapses a+ # doubled-dollar variable reference to a bare dollar sign.+ entrypoint:+ - /bin/sh+ - -c+ - |+ (+ while true; do+ printf 's3.configure -access_key=object_storage_root_user -secret_key=object_storage_root_password -user=posthog -actions=Admin -apply\ns3.bucket.create -name posthog\ns3.bucket.create -name ai-blobs\n' \+ | /usr/bin/weed shell -master=localhost:19001 >/dev/null 2>&1 || true+ if echo 's3.bucket.list' | /usr/bin/weed shell -master=localhost:19001 2>/dev/null | grep -q ai-blobs \+ && echo 's3.configure' | /usr/bin/weed shell -master=localhost:19001 2>/dev/null | grep -q object_storage_root_user; then+ touch /tmp/objectstorage-ready+ echo "Objectstorage SeaweedFS ready with required buckets and identities"+ break+ fi+ sleep 1+ done+ ) &+ exec /usr/bin/weed "$$@"+ - --+ # A new volume. SeaweedFS cannot read the MinIO layout, so the old objects stay on+ # the `objectstorage` volume until the operator copies them across with+ # bin/migrate-storage-hobby or deletes the volume.volumes:- - objectstorage:/data+ - objectstorage-data:/dataports:- - '19000:19000'- - '19001:19001'+ # Localhost only. MinIO published this port on every interface.+ - '127.0.0.1:19000:19000'seaweedfs:extends:@@ -718,7 +744,7 @@ volumes:zookeeper-data:zookeeper-datalog:zookeeper-logs:- objectstorage:+ objectstorage-data:seaweedfs:postgres-data:clickhouse-data:diff --git a/docs/internal/hobby-minio-removal.md b/docs/internal/hobby-minio-removal.mdnew file mode 100644index 000000000000..741ea82c2607--- /dev/null+++ b/docs/internal/hobby-minio-removal.md@@ -0,0 +1,81 @@+# Hobby: moving object storage off MinIO++PostHog's hobby stack used two object stores: MinIO on `objectstorage:19000` for general storage, and SeaweedFS on `seaweedfs:8333` for session replay v2.+MinIO stopped publishing Docker images, so the `objectstorage` service now runs SeaweedFS as well.++SeaweedFS cannot read the MinIO on-disk format, and there is no in-place conversion.+The service starts on a new `objectstorage-data` volume, and the MinIO data stays where it is, on the `objectstorage` volume.++## What becomes unavailable++Until you copy the objects across, PostHog cannot read:++- exported assets (CSV, PNG, PDF, video)+- uploaded media, such as images in notebooks+- error tracking symbol sets, so stack traces stay unsymbolicated+- session recordings that are still in MinIO++Postgres and ClickHouse are untouched.+Events, persons, insights, dashboards, feature flags and experiments all survive the upgrade.++## Option 1: copy the objects after the upgrade++This is the usual path.+`bin/upgrade-hobby` asks you to acknowledge the change before it pulls the new version, and it keeps the old volume.++Upgrade first, wait for the stack to come up, then run this from the directory that holds your `docker-compose.yml`:++```bash+./posthog/bin/migrate-storage-hobby --dry-run # see what would be copied+./posthog/bin/migrate-storage-hobby # copy it+```++The script starts a temporary MinIO container on the stack's network, mounted on the old volume, and copies bucket contents through the running services.+It copies:++- the whole `posthog` bucket into `objectstorage`, so a prefix that no list here mentions still comes across+- the `ai-blobs` bucket into `objectstorage`+- session recordings into `seaweedfs`+- symbol sets into `seaweedfs` as well, because cymbal reads them there while Django reads them from `objectstorage`++The query cache is the one thing left behind, because PostHog rebuilds it.++The copy skips objects that already exist in the destination, so it is safe to run again after a failure.+It exits non-zero if any object failed, and it only suggests deleting the old volume after a complete run.++Check your data in PostHog before you free the disk space:++```bash+docker volume rm <project>_objectstorage+```++The script prints the volume name it read.+It picks that volume by name (`<project>_objectstorage`) and refuses to guess when a host holds more than one, so pass `--volume <id>` if you run several installs on one machine.++## Upgrading through the installer instead++`bin/hobby-installer` does not run `bin/upgrade-hobby`, so it cannot show that prompt.+Its preflight checks warn instead, whenever the legacy volume is still on the host, and ask you to confirm before the upgrade continues.+The warning clears once you copy the objects across and delete the old volume.++## Option 2: stay on your current version++Answer `N` at the upgrade prompt.+Nothing changes, and you keep a running MinIO.+Copy the `posthog` bucket out with any S3 client against `http://127.0.0.1:19000`, with access key `object_storage_root_user` and secret `object_storage_root_password`, then upgrade.++This option matters most if you cannot pull `quay.io/minio/minio`, which option 1 needs.++## If the copy does not work++The temporary container reads a pinned MinIO release from Quay.+MinIO archived its source repository in October 2025, so that image can disappear.+If the pull fails, the objects are still on the volume.+Mount it on any host that can still run MinIO, start MinIO against it, and copy the bucket out with an S3 client.++## Why the anonymous identity is off in hobby++Dev and CI register an `anonymous` SeaweedFS identity with Admin rights, so unsigned clients keep working.+Hobby does not, because Caddy proxies `/posthog/*` straight to `objectstorage`.+An anonymous identity there makes every object readable and writable from the internet.+Only the `posthog` identity is registered, so SeaweedFS rejects unsigned requests and the presigned URLs Django hands out keep working.diff --git a/hogli.yaml b/hogli.yamlindex 74570cc85bcf..f69b26f0ed0d 100644--- a/hogli.yaml+++ b/hogli.yaml@@ -449,25 +449,23 @@ deploy:description: Upgrade existing hobby deployment with data loss warnings and volumechecksprompt: true- deploy:migrate-recordings:- bin_script: migrate-session-recordings-hobby- description: Migrate session recordings from MinIO to SeaweedFS for hobby deploymentsdeploy:migrate-storage:bin_script: migrate-minio-to-seaweedfsdescription: "Migrate or sync object storage between MinIO and SeaweedFS\n\nServices:\\ session-recordings, session-recordings-lts, query-cache, \n media-uploads,\- \ exports, source-maps\n\nModes:\n --mode migrate One-way copy (default)\n\- \ --mode sync Bidirectional sync\n\nExamples:\n hogli deploy:migrate-storage\- \ --service query-cache --mode sync --dry-run\n hogli deploy:migrate-storage\- \ --service media-uploads --mode migrate"+ \ exports, source-maps, ai-blobs, general-storage\n\nModes:\n --mode migrate\+ \ One-way copy (default)\n --mode sync Bidirectional sync\n\nExamples:\+ \n hogli deploy:migrate-storage --service query-cache --mode sync --dry-run\+ \n hogli deploy:migrate-storage --service media-uploads --mode migrate"prompt: truedeploy:migrate-storage-hobby:bin_script: migrate-storage-hobby- description: "Hobby: Migrate or sync ALL services between MinIO and SeaweedFS\- \ via docker-compose\n\nExamples:\n hogli deploy:migrate-storage-hobby \- \ # Sync all services\n hogli deploy:migrate-storage-hobby --mode\- \ migrate # One-way migrate all (MinIO \u2192 SeaweedFS)\n hogli deploy:migrate-storage-hobby\- \ exports -n # Dry run exports only"+ description: "Hobby: copy object storage out of the legacy MinIO volume into\+ \ SeaweedFS\n\nRuns against a temporary MinIO container, so the stack no longer\+ \ needs a MinIO service.\n\nExamples:\n hogli deploy:migrate-storage-hobby\+ \ # Copy every service\n hogli deploy:migrate-storage-hobby\+ \ exports -n # Dry run exports only\n hogli deploy:migrate-storage-hobby\+ \ --list # List the MinIO volumes on this host"prompt: truedeploy:upgrade-objectstorage:bin_script: upgrade-objectstoragediff --git a/nodejs/bin/migrate-minio-to-seaweedfs.js b/nodejs/bin/migrate-minio-to-seaweedfs.jsindex da1e809496c3..62d12106a480 100755--- a/nodejs/bin/migrate-minio-to-seaweedfs.js+++ b/nodejs/bin/migrate-minio-to-seaweedfs.js@@ -33,6 +33,8 @@* media-uploads User uploaded media* exports Exported assets (CSV, PNG, PDF, videos)* source-maps Error tracking source maps+ * ai-blobs Offloaded AI payloads (separate bucket)+ * general-storage The whole posthog bucket, minus session recordings and query cache*/const {@@ -92,6 +94,28 @@ const SERVICES = {conflictResolution: 'newest',critical: true,},+ 'ai-blobs': {+ bucket: 'ai-blobs',+ prefix: 'aio/',+ description: 'Offloaded AI payloads',+ bidirectional: true,+ conflictResolution: 'newest',+ critical: true,+ },+ // The posthog bucket holds far more prefixes than the named services above+ // (tasks, legal documents, notebook frames, identity matching, and every prefix a+ // product adds later), so a salvage that copies only those loses the rest. This+ // service covers the bucket and carves out what belongs elsewhere: session+ // recordings live in the SeaweedFS replay store, and PostHog rebuilds the query cache.+ 'general-storage': {+ bucket: 'posthog',+ prefix: '',+ excludePrefixes: ['session_recordings/', 'session_recordings_lts/', 'query_cache/'],+ description: 'The whole posthog bucket, minus session recordings and query cache',+ bidirectional: false,+ conflictResolution: 'newest',+ critical: true,+ },}// Checkpoint file for resumable migrations@@ -453,6 +477,13 @@ async function listAllObjectsWithMetadata(client, bucket, prefix) {return allObjects}+function excludeByPrefix(objects, config) {+ if (!config.excludePrefixes || config.excludePrefixes.length === 0) {+ return objects+ }+ return objects.filter((obj) => !config.excludePrefixes.some((prefix) => obj.Key.startsWith(prefix)))+}+function needsSync(objA, objB) {// Different size = different contentif (objA.Size !== objB.Size) return true@@ -578,6 +609,8 @@ async function migrateService(serviceName, config, options, checkpoint) {continuationToken = response.NextContinuationToken} while (continuationToken)+ allObjects = excludeByPrefix(allObjects, config)+console.log(`✅ Found ${allObjects.length} objects`)if (allObjects.length === 0) {@@ -678,6 +711,9 @@ async function migrateService(serviceName, config, options, checkpoint) {console.log(` ... and ${failedObjects.length - 10} more`)}console.log(`\n💡 Run with --resume to retry failed objects`)+ // A caller that deletes the source after this has to be able to tell a clean copy+ // from a partial one, and the summary above is the only other signal.+ throw new Error(`${failedObjects.length} of ${objectsToProcess.length} objects failed to copy`)}}@@ -712,10 +748,12 @@ async function syncService(serviceName, config, options, checkpoint) {// List objects from both sidesconsole.log(`📋 Listing objects from both storages...`)- const [minioObjects, seaweedfsObjects] = await Promise.all([+ const [allMinioObjects, allSeaweedfsObjects] = await Promise.all([listAllObjectsWithMetadata(minioClient, config.bucket, config.prefix),listAllObjectsWithMetadata(seaweedfsClient, config.bucket, config.prefix),])+ const minioObjects = excludeByPrefix(allMinioObjects, config)+ const seaweedfsObjects = excludeByPrefix(allSeaweedfsObjects, config)console.log(`✅ MinIO: ${minioObjects.length} objects`)console.log(`✅ SeaweedFS: ${seaweedfsObjects.length} objects`)