I decided to run Kanboard, an open source project management application, in a rootless Podman pod as a small weekend project. The pod consists of three containers, an infra-container, a kanboard-container, and a postgresql-container. That deployment went well, but eventually, the image I used for the postgresql-container became deprecated, meaning it was no longer receiving updates. It was time to move to a different image, but that meant migrating a database between containers. It sounds intimidating, but the process is actually straightforward. Here's how to do it.
Migrate to an upgraded PostgreSQL
The process for migrating a database in containers is mostly the same as it is for any other database, but with an additional step to manage containers. Here's an outline of the steps I took:
- Back up the current database.
- Stop and remove the container.
- Delete the directory and files of the old PostgreSQL version from the Podman volume.
- Move the SQL dump file to the Podman volume.
- Start the pod with the rhel8/postgresql-13 container.
- Restore the database.
[ Download the Bash shell scripting cheat sheet. ]
Here are the steps broken down.
First, back up the database:
$ podman exec -t [container name] \
/usr/bin/pg_dump [database name] > dump.sql
Next, empty the Podman volume of the database:
$ podman volume inspect [volume name]
$ sudo rm -rf \
~/.local/share/containers/storage/volumes/[volume name]/_data/*
Now move the database dump to the Podman volume:
$ mv dump.sql \
~/.local/share/containers/storage/volumes/[volume name>]/_data/
Note: be sure to start the postgresql-cotainer using the new container image rhel8/postgresql-13:
$ podman run -d --pod [pod name] --name [container name] \
-e POSTGRESQL_USER=root \
-e POSTGRESQL_PASSWORD=SecretPassword \
-e POSTGRESQL_DATABASE=[database name] \
-v [volume name]:/var/lib/pgsql/data:Z rhel8/postgresql-13
And finally, restore the database to the container:
$ podman exec -it [container name] bash
$ psql -U [user name] -d [database name] \
< /var/lib/pgsql/data/dump.sql
Give it a try
Migrating to a new database release in containers is not difficult when you know the steps. I also think you can apply these procedures to other databases that run in containers.
Haven't started your container journey yet? Well, you might begin with Alexon Oliveira's article on Podman scripting.
저자 소개
Jörg has been a Sysadmin for over ten years now. His fields of operation include Virtualization (VMware), Linux System Administration and Automation (RHEL), Firewalling (Forcepoint), and Loadbalancing (F5). He is a member of the Red Hat Accelerators Community and author of his personal blog at https://www.my-it-brain.de.
유사한 검색 결과
Bridging the gap: Red Hat Academy shaping open source talent in APAC
From banking to tech: Bradley's Red Hat journey
What’s The Recipe For Burnout? | Compiler
Weird data science | Technically Speaking
채널별 검색
오토메이션
기술, 팀, 인프라를 위한 IT 자동화 최신 동향
인공지능
고객이 어디서나 AI 워크로드를 실행할 수 있도록 지원하는 플랫폼 업데이트
오픈 하이브리드 클라우드
하이브리드 클라우드로 더욱 유연한 미래를 구축하는 방법을 알아보세요
보안
환경과 기술 전반에 걸쳐 리스크를 감소하는 방법에 대한 최신 정보
엣지 컴퓨팅
엣지에서의 운영을 단순화하는 플랫폼 업데이트
인프라
세계적으로 인정받은 기업용 Linux 플랫폼에 대한 최신 정보
애플리케이션
복잡한 애플리케이션에 대한 솔루션 더 보기
가상화
온프레미스와 클라우드 환경에서 워크로드를 유연하게 운영하기 위한 엔터프라이즈 가상화의 미래