discourse数据库PostgreSQL 15升级方法

discourse基本每年都会对数据库的版本做一次大的升级

之前因为备份数据和数据库版本没有对应起来,导致备份数据恢复异常,在构建容器时,postgres.15.template.yml模板中的15为数据库的版本

升级过程中需要根据历史模板按顺序依次构建容器,无法越版本升级构建,需要依次使用以下模板构建容器

本次升级从13->15升级,如果小于13的数据库,原理一致

postgres.13.template.yml
postgres.15.template.yml
postgres.template.yml

docker镜像使用discourse/base:2.0.20250129-0720版本
如果使用的是中国网络,postgres.13.template.yml、postgres.15.template.yml做配置做apt中国网络加速

run:
  - exec: cat /etc/os-release && psql --version
  - exec: |
      if [ -f /etc/apt/sources.list ]; then
        sudo sed -i 's/deb.debian.org/mirrors.ustc.edu.cn/g' /etc/apt/sources.list
      else
        echo "deb http://mirrors.ustc.edu.cn/debian bookworm main contrib non-free non-free-firmware" | sudo tee /etc/apt/sources.list
        echo "deb http://mirrors.ustc.edu.cn/debian bookworm-updates main contrib non-free non-free-firmware" | sudo tee -a /etc/apt/sources.list
      fi
  - exec: |
      if [ -f /etc/apt/sources.list.d/debian.sources ]; then
        sudo sed -i 's/deb.debian.org/mirrors.ustc.edu.cn/g' /etc/apt/sources.list.d/debian.sources
      else
        sudo bash -c 'cat > /etc/apt/sources.list.d/debian.sources <<EOF
        URIs: http://mirrors.ustc.edu.cn/debian
        Suites: bookworm bookworm-updates
        Components: main contrib non-free non-free-firmware
        Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg

        Types: deb
        URIs: http://mirrors.ustc.edu.cn/debian-security
        Suites: bookworm-security
        Components: main contrib non-free non-free-firmware
        Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg
        EOF'
      fi
  - exec: cat /etc/apt/sources.list && cat /etc/apt/sources.list.d/debian.sources
1 Like

discourse低成本搭建、不停服务升级更新、deepseek人工智能模型引入,所有依赖库中国网络加速,欢迎交流

本人论坛
https://www.zeppos.tech/t/topic/13544?u=sober

论坛最新同步更新