This commit is contained in:
@@ -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/
|
||||
|
||||
Reference in New Issue
Block a user