0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

一人アドカレ 11日目: Postgresusの紹介

Last updated at Posted at 2025-12-22

PostgresusはDatabasusになりました。
Databasusになったことで、PostgreSQL以外もサポートされましたが、Postgresusからの移行はマニュアル移行を推奨されています。
Databasusに変わったことで、image以外にもマウント位置などが変わっていますので、Databasusとして利用の際はご注意ください。

イントロ

みなさま、データベースのバックアップどうしていますか?

正直私はほとんどしていませんでした・・・
そんな中良さそうなものを見つけたので建てたばかりのPostgresusを紹介!

PostgreSQL専用となりますが、私が触ってる環境のほとんどはPostgreSQL。(今回のアドベントカレンダーで紹介するサービスのうち、Kodbox以外は全てPostgreSQLです)
S3互換ストレージにバックアップを保存でき、失敗した時だけメール通知、WebHookなどのカスタマイズも可能だったので導入しました。

Postgresusの使い方

環境情報
$ docker version
Client: Docker Engine - Community
 Version:           29.1.3
 API version:       1.52
 Go version:        go1.25.5
 Git commit:        f52814d
 Built:             Fri Dec 12 14:49:51 2025
 OS/Arch:           linux/amd64
 Context:           default

Server: Docker Engine - Community
 Engine:
  Version:          29.1.3
  API version:      1.52 (minimum version 1.44)
  Go version:       go1.25.5
  Git commit:        fbf3ed2
  Built:            Fri Dec 12 14:49:51 2025
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          v2.2.0
  GitCommit:        1c4457e00facac03ce1d75f7b6777a7a851e5c41
 runc:
  Version:          1.3.4
  GitCommit:        v1.3.4-0-gd6d73eb8
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

前提条件

  • Docker がインストールされていること
  • Traefik が導入されていること(リバースプロキシサーバー)

手順

  1. バックアップするためのDB用のネットワークを作成する

    docker network create postgres-backup-network
    
  2. compose.ymlを作成します

    domain.tldは自分の環境に合わせて変更してください。https://postgresus.domain.tldでアクセスできるようになります。

    compose.yml
    services:
      postgresus:
        image: rostislavdugin/postgresus
        container_name: postgresus
        restart: unless-stopped
        expose:
          - 4005
        volumes:
          - ./backup:/postgresus-data
        labels:
          traefik.enable: true
          traefik.http.services.postgresus.loadbalancer.server.port: 4005
          traefik.http.routers.postgresus.rule: Host(`postgresus.domain.tld`)
          traefik.http.routers.postgresus.entrypoints: websecure
          traefik.http.routers.postgresus.tls: true
          traefik.http.routers.postgresus.tls.certResolver: cloudflare
          traefik.docker.network: traefik-network
          glance.name: Postgresus
          glance.icon: https://cdn.jsdelivr.net/gh/selfhst/icons@main/png/postgresus.png
          glance.url: https://postgresus.domain.tld/
          glance.description: PostgreSQL backup tool
        networks:
          - traefik-network
          - postgres-backup-network
    
    networks:
      traefik-network:
        external: true
      postgres-backup-network:
        external: true
    
  3. 他のPostgreSQLコンテナと同じネットワークにpostgres-backup-networkを追加する

    例: Ente Photoの場合

    compose.yml
    services:
      postgres:
        image: postgres:15-trixie
        container_name: ente-db
        # 省略
        networks:
          - ente
          - postgres-backup-network
    networks:
      ente:
      traefik-network:
        external: true
      postgres-backup-network:
        external: true
    
  4. Postgresusコンテナを起動します

    docker compose up -d
    
  5. https://postgresus.domain.tldにアクセスし、PostgreSQLの接続情報を入力して保存します。

    あとはバックアップスケジュールを設定すればOKです。

簡単なスクショ

11.postgresus.png

Postgresusの感想

  • 良いところ
    • シンプルでわかりやすいUI
    • S3互換ストレージに対応
    • バックアップの通知設定が柔軟(メール、WebHookなど)
    • WebUIから簡単にリストアが可能
    • データベース接続時、読み取り専用ユーザーを自動で作ってくれる(オプション)
  • イマイチなところ
    • PostgreSQL専用(特に困ってはない)
    • OIDCが欲しかった...

以上、Postgresusの紹介でした。
まだ、導入してから1週間も経っていませんが、特に問題なし。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?