feat: add migration completion tracking to installation script

This commit is contained in:
Anish Sarkar 2026-02-27 22:59:51 +05:30
parent 57a1c71582
commit 6e1ca96d57

View file

@ -30,6 +30,7 @@ INSTALL_DIR="./surfsense"
OLD_VOLUME="surfsense-data" OLD_VOLUME="surfsense-data"
DUMP_FILE="./surfsense_migration_backup.sql" DUMP_FILE="./surfsense_migration_backup.sql"
KEY_FILE="./surfsense_migration_secret.key" KEY_FILE="./surfsense_migration_secret.key"
MIGRATION_DONE_FILE="${INSTALL_DIR}/.migration_done"
MIGRATION_MODE=false MIGRATION_MODE=false
SETUP_WATCHTOWER=true SETUP_WATCHTOWER=true
WATCHTOWER_INTERVAL=86400 WATCHTOWER_INTERVAL=86400
@ -127,7 +128,8 @@ success "All files downloaded to ${INSTALL_DIR}/"
# If a dump already exists (from a previous partial run) skip extraction and # If a dump already exists (from a previous partial run) skip extraction and
# go straight to restore — this makes re-runs safe and idempotent. # go straight to restore — this makes re-runs safe and idempotent.
if docker volume ls --format '{{.Name}}' 2>/dev/null < /dev/null | grep -q "^${OLD_VOLUME}$"; then if docker volume ls --format '{{.Name}}' 2>/dev/null < /dev/null | grep -q "^${OLD_VOLUME}$" \
&& [[ ! -f "${MIGRATION_DONE_FILE}" ]]; then
MIGRATION_MODE=true MIGRATION_MODE=true
if [[ -f "${DUMP_FILE}" ]]; then if [[ -f "${DUMP_FILE}" ]]; then
@ -235,6 +237,7 @@ if $MIGRATION_MODE; then
warn "The restore may have failed silently. Check: cd ${INSTALL_DIR} && ${DC} logs db" warn "The restore may have failed silently. Check: cd ${INSTALL_DIR} && ${DC} logs db"
else else
success "Smoke test passed: ${TABLE_COUNT} table(s) restored successfully." success "Smoke test passed: ${TABLE_COUNT} table(s) restored successfully."
touch "${MIGRATION_DONE_FILE}"
fi fi
step "Starting all SurfSense services" step "Starting all SurfSense services"
@ -323,9 +326,10 @@ info ""
if $MIGRATION_MODE; then if $MIGRATION_MODE; then
warn " Migration complete! Open frontend and verify your data." warn " Migration complete! Open frontend and verify your data."
warn " Once verified, clean up the legacy volume and dump file:" warn " Once verified, clean up the legacy volume and migration files:"
warn " docker volume rm ${OLD_VOLUME}" warn " docker volume rm ${OLD_VOLUME}"
warn " rm ${DUMP_FILE}" warn " rm ${DUMP_FILE}"
warn " rm ${MIGRATION_DONE_FILE}"
else else
warn " First startup may take a few minutes while images are pulled." warn " First startup may take a few minutes while images are pulled."
warn " Edit ${INSTALL_DIR}/.env to configure API keys, OAuth, etc." warn " Edit ${INSTALL_DIR}/.env to configure API keys, OAuth, etc."