Skip to content

Instantly share code, notes, and snippets.

@thebapi
Last active August 28, 2023 11:50
Show Gist options
  • Select an option

  • Save thebapi/82a3508bc11a7bc5558c75f90d2215e4 to your computer and use it in GitHub Desktop.

Select an option

Save thebapi/82a3508bc11a7bc5558c75f90d2215e4 to your computer and use it in GitHub Desktop.
This document is intended for upgrading PostgreSQL 12 database to PostgreSQL 14 or timescale/timescaledb:2.9.1-pg14 db
Inside the docker container
1. cd root
2. pg_dumpall -U postgres -v > $HOME/upgrade_backup.sql
3. touch pg_extract.sh
4. Write the following command into the pg_extract.sh file
#!/bin/bash
[ $# -lt 2 ] && { echo "Usage: $0 <postgresql dump> <dbname>"; exit 1; }
sed "/connect.*$2/,\$!d" $1 | sed "/PostgreSQL database dump complete/,\$d" > pg_extract.sh
5. chmod +x pg_extract.sh
6. ./pg_extract.sh upgrade_backup.sql sematics >> upgrade_backup_sematics.sql
7. Create a new docker container using the image timescale/timescaledb:2.9.1-pg14 and move the file upgrade_backup_sematics.sql into the new container’s root folder
8. Inside the new container’s root folder please execute the following command
cat upgrade_backup_sematics.sql | psql -U postgres
Original article https://thomasbandt.com/postgres-docker-major-version-upgrade
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment