Postgres SQL 11 to 16 upgrade tool #3146
gadgetusaf
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hey everyone, Had a bit of fun getting the database upgraded when I upgraded my conatiner. This will properly upgrade your database. you may need to tweak for a differnt version but this worked great for me.
Youll need to replace your-password in both the upgrade.sh script and the Dockerfile.
Ensure that Docker and docker-compose are installed on your system.
Determine the path to your existing PostgreSQL 11 data directory. This is typically
/var/lib/postgresql/11/data
.Choose a new path where you want the upgraded PostgreSQL 16 data to be saved. For example,
/path/to/new/folder
.Change the ownership of the new path to the user ID of the process that will run the upgraded database. You can do this by running the following command:
Create a new empty folder and navigate to it in your terminal.
In this folder, create two files:
upgrade.sh
andDockerfile
. Copy the contents of the providedupgrade.sh
andDockerfile
into their respective files.Make the
upgrade.sh
script executable by running the following command:Build the Docker image by running the following command:
Ensure that all related containers are stopped. If you used docker-compose to start your containers, make sure to stop them using the following command:
Run the upgrade process using the following command, replacing
/psql11/path
with the path to your existing PostgreSQL 11 data directory and/psql16/path
with the path where you want the upgraded data to be saved:After the upgrade process is complete, modify the path in your application's configuration to point to the new PostgreSQL 16 data location (
/psql16/path
).Note: Make sure to replace
your-password
in theupgrade.sh
script andDockerfile
with your actual PostgreSQL password.upgrade.sh
dockerfile
Beta Was this translation helpful? Give feedback.
All reactions