From 45fd597651ee6ddf923e02809471921b3549d4d1 Mon Sep 17 00:00:00 2001 From: Roman Vanicek Date: Sun, 29 Mar 2026 00:39:04 +0000 Subject: [PATCH] Fix automatic upgrade --- upgrade-entrypoint.sh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/upgrade-entrypoint.sh b/upgrade-entrypoint.sh index 64ecb2d..b726c1a 100644 --- a/upgrade-entrypoint.sh +++ b/upgrade-entrypoint.sh @@ -11,15 +11,18 @@ if [ -f "$OLD_VERSION_FILE" ]; then if [ "$OLD_VERSION" != "$NEW_VERSION" ]; then echo "Data version ($OLD_VERSION) differs from engine ($NEW_VERSION). Starting upgrade..." - # 1. Move old data to a temporary folder + # Move old data to a temporary folder mkdir -p $DATA_DIR/old_data mv $DATA_DIR/* $DATA_DIR/old_data/ || true - # 2. Initialize new data directory + # Initialize new data directory mkdir $DATA_DIR/new_data initdb -D $DATA_DIR/new_data + + # Prevent error "You must have read and write access in the current directory." + cd $DATA_DIR - # 3. Run pg_upgrade + # Run pg_upgrade # --link is used to avoid copying files (fast, but requires a backup!) pg_upgrade \ -d $DATA_DIR/old_data \ @@ -27,7 +30,8 @@ if [ -f "$OLD_VERSION_FILE" ]; then -b /usr/bin/postgres-16 \ -B /usr/local/bin \ --link - + + # Clean-up echo "Upgrade complete. Cleaning up..." rm -rf $DATA_DIR/old_data mv $DATA_DIR/new_data/* $DATA_DIR/