Comments (4)
Just include i.e. --locale=C.UTF-8
in -e POSTGRES_INITDB_ARGS=""
.
Example, adapted from @jooize:
POSTGRES_USER="synapse"
POSTGRES_PASSWORD="synapse-password"
PG_LOCALE="C.UTF-8"
OLD=11
NEW=12
OLD_DATA="/matrix/postgres/data-auto-upgrade-backup"
NEW_DATA="/matrix/postgres/data"
sudo docker run --rm \
-e PGUSER="$POSTGRES_USER" \
-e POSTGRES_INITDB_ARGS="-U $POSTGRES_USER --locale=$PG_LOCALE" \
-e POSTGRES_PASSWORD="$POSTGRES_PASSWORD" \
-v "$OLD_DATA":"/var/lib/postgresql/$OLD/data" \
-v "$NEW_DATA":"/var/lib/postgresql/$NEW/data" \
"tianon/postgres-upgrade:$OLD-to-$NEW"
from docker-postgres-upgrade.
Does not work here.
sudo docker run --rm \
-e PGUSER=mydbuser \
-e POSTGRES_INITDB_ARGS='-U mydbuser --locale=C.UTF-8' \
-e POSTGRES_PASSWORD="xxx" \
-v /DB_MIGRATION/9.6:/var/lib/postgresql/9.6/data \
-v /DB_MIGRATION/13:/var/lib/postgresql/13/data \
tianon/postgres-upgrade:9.6-to-13
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.
The database cluster will be initialized with locale "en_US.utf8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".
Data page checksums are disabled.
fixing permissions on existing directory /var/lib/postgresql/13/data ... ok
creating subdirectories ... ok
selecting dynamic shared memory implementation ... posix
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting default time zone ... Etc/UTC
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... ok
Success. You can now start the database server using:
pg_ctl -D /var/lib/postgresql/13/data -l logfile start
initdb: warning: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the option -A, or
--auth-local and --auth-host, the next time you run initdb.
Performing Consistency Checks
-----------------------------
Checking cluster versions ok
connection to database failed: FATAL: database locale is incompatible with operating system
DETAIL: The database was initialized with LC_COLLATE "utf-8", which is not recognized by setlocale().
HINT: Recreate the database with another locale or install the missing locale.
Failure, exiting
from docker-postgres-upgrade.
I just realized that I misread your logs. Basically, postgresql tells you that your database was initialized with an unknown LC_COLLATE value, which was set to "utf-8" (instead of i.e. C or C.UTF-8). To my knowledge, there's now way to get that right after creation. So before upgrading your database, you will have to drop the old database, create a new one and update your new one with your old data. Follow i.e. this tutorial.
Afterwards you should be able to update to a new version using this dockerized solution.
Sorry again for this confusion! My provided solution only works if you created a database with known locale settings.
from docker-postgres-upgrade.
hi, i'm facing a similar problem that should be fixed by the script you suggested, but it seems that POSTGRES_INITDB_ARGS is ignored.
I get this error:
lc_collate values for database "postgres" do not match: old "en_US.utf8", new "C.UTF-8"
setting PG_LOCALE as en_US.utf8, this is my scirpt:
POSTGRES_USER="*********"
POSTGRES_PASSWORD="*********"
PG_LOCALE="en_US.utf8"
OLD=10
NEW=13
OLD_DATA="/pgdata"
NEW_DATA="/pgdata-next"
sudo docker run --rm \
-e PGUSER="$POSTGRES_USER" \
-e POSTGRES_INITDB_ARGS="-U $POSTGRES_USER --locale=$PG_LOCALE" \
-e POSTGRES_PASSWORD="$POSTGRES_PASSWORD" \
-v "$OLD_DATA":"/var/lib/postgresql/$OLD/data" \
-v "$NEW_DATA":"/var/lib/postgresql/$NEW/data" \
"tianon/postgres-upgrade:$OLD-to-$NEW"
thank you for your support.
from docker-postgres-upgrade.
Related Issues (20)
- wont start - fails to find socket of source postgres HOT 2
- Upgrading from 14 to 15 failing with `"/var/lib/postgresql/14/data/PG_VERSION": No such file or directory` HOT 5
- Docker image should run pg_upgrade's generated update_extension.sql file when present HOT 2
- support custom username for example "-U my_username" when connecting HOT 6
- Break database made with Alpine-based container HOT 6
- PostgreSQL 16 HOT 3
- TO VERSION 16 HOT 1
- 11 to VERSION 16 REQUEST HOT 1
- Cannot create directory: File exists. HOT 1
- Docker image for ARM64 (aarch64 / Arm Ampere) architecture HOT 1
- "could not create any Unix-domain sockets" HOT 2
- Add ARM Arch Support HOT 1
- Does the operation of `exec gosu postgres "$BASH_SOURCE" "$@"` overlap with `exec "$@"`? HOT 4
- 13-to-15: FATAL: role "postgres" does not exist HOT 2
- How to support PostgreSQL database upgrade with multiple tablespaces HOT 1
- Collation warning
- script to review when username is not postgres - permission issue
- Is there a reason to remove upgrade ability for older versions? HOT 2
- chown fails
- Support for linux/arm64/v8 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from docker-postgres-upgrade.