简体   繁体   English

如何将 dockerized postgres 从 11 升级到 12

[英]How to Upgrading dockerized postgres from 11 to 12

So as the title says i have a dockerized postgres database on a rails app.所以正如标题所说,我在 Rails 应用程序上有一个 dockerized postgres 数据库。 I'm just wondering how i'd go about upgrading the postgres version.我只是想知道我如何 go 关于升级 postgres 版本。 I havn't done any upgade work before so I'm don't want to lose data.我以前没有做过任何升级工作,所以我不想丢失数据。

docker-compose file docker-compose文件

  postgres:
    image: postgres:11.5
    ports:
      - "5432:5432"
    volumes:
      - postgres_data:/var/lib/postgresql/data
    env_file:
      .docker.env

You can use pg_dumpall command for upgrading eg 11.x to 12.x:您可以使用pg_dumpall命令将例如 11.x 升级到 12.x:

  1. Backup your old database备份旧数据库
docker exec -it <your-old-postgres-container-id> /usr/bin/pg_dumpall -U <postgres-username> backupfile   #postgres-username='postgres'
  1. Start new container with new Postgres version ( Note! with new volume mount )使用新的 Postgres 版本启动新容器(注意!使用新的卷挂载
  2. Import backuped file into new container将备份文件导入新容器
ocker exec -it <new-postgres-container-id> psql < backupfile
  1. Stop old container and verify Import in new container停止旧容器并验证在新容器中导入

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM