Fix issue with checksums
This commit is contained in:
18
migrate.sh
18
migrate.sh
@@ -1,6 +1,9 @@
|
||||
#!/bin/bash
|
||||
echo Migrate PostgreSQL version
|
||||
|
||||
OLD_POSTGRES=/postgres/17
|
||||
NEW_POSTGRES=/postgres/18
|
||||
|
||||
DB_PATH=/db
|
||||
OLD_DB_PATH=/tmp/old_db
|
||||
NEW_DB_PATH=/tmp/new_db
|
||||
@@ -12,17 +15,26 @@ then
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
# Run database on a COPY of the database
|
||||
# Run migration on a COPY of the database
|
||||
cp -r "$DB_PATH" "$OLD_DB_PATH"
|
||||
|
||||
# Initialize NEW database
|
||||
mkdir "$NEW_DB_PATH"
|
||||
/postgres/18/bin/initdb -D "$NEW_DB_PATH" --username "$POSTGRES_USER" --pwfile=<(printf "%s\n" "$POSTGRES_PASSWORD") || exit 1
|
||||
$NEW_POSTGRES/bin/initdb -D "$NEW_DB_PATH" --username "$POSTGRES_USER" --pwfile=<(printf "%s\n" "$POSTGRES_PASSWORD") || exit 1
|
||||
|
||||
# Enable / disable checksum on new database, depending on the configuration of the old one
|
||||
if $OLD_POSTGRES/bin/pg_checksums -c "$OLD_DB_PATH";
|
||||
then
|
||||
echo Enable checksums on new database
|
||||
$NEW_POSTGRES/bin/pg_checksums -e "$NEW_DB_PATH"
|
||||
else
|
||||
echo Disable checksums on new database
|
||||
$NEW_POSTGRES/bin/pg_checksums -d "$NEW_DB_PATH"
|
||||
fi
|
||||
|
||||
# Perform migration
|
||||
cd /tmp
|
||||
/postgres/18/bin/pg_upgrade -b /postgres/17/bin/ -d "$OLD_DB_PATH" -D "$NEW_DB_PATH" -U "$POSTGRES_USER" || exit 2
|
||||
$NEW_POSTGRES/bin/pg_upgrade -b $OLD_POSTGRES/bin/ -d "$OLD_DB_PATH" -D "$NEW_DB_PATH" -U "$POSTGRES_USER" || exit 2
|
||||
|
||||
# Configure database server
|
||||
echo Configure database server
|
||||
|
Reference in New Issue
Block a user