#!/bin/bash # One-time, idempotent, NON-destructive migration of uploads + backups from a # legacy bitnami discourse volume into the official image's /shared. # # Runs on every boot as a runit 1.d hook but no-ops after the first success # (sentinel) and when there is no legacy volume mounted (fresh installs). It only # ever COPIES from the read-only /legacy mount, so an interruption just re-copies # on the next boot — there is no move/delete to leave the data half-migrated. set -e SENTINEL=/shared/.bitnami-uploads-migrated [ -e "$SENTINEL" ] && exit 0 if [ -d /legacy/public/uploads ]; then echo "[migrate-uploads] copying bitnami uploads/backups -> /shared" mkdir -p /shared/uploads /shared/backups cp -a /legacy/public/uploads/. /shared/uploads/ 2>/dev/null || true cp -a /legacy/public/backups/. /shared/backups/ 2>/dev/null || true # discourse runs as uid 1000; the official boot also chowns /shared, but be explicit chown -R discourse:discourse /shared/uploads /shared/backups 2>/dev/null || true echo "[migrate-uploads] done" fi touch "$SENTINEL"